/**
 * RFP Mailbox Frontend Styles
 */

/* Notification styles (matching RFP style) */
.brixzly-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 6px;
    color: white;
    font-weight: 500;
    z-index: 10000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 350px;
}

.brixzly-notification.show {
    transform: translateX(0);
}

.brixzly-notification.success {
    background: linear-gradient(135deg, #00a32a, #007e23);
}

.brixzly-notification.error {
    background: linear-gradient(135deg, #d63638, #b32d2e);
}

/* Confirmation modal styles (matching RFP style) */
.brixzly-confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brixzly-confirm-dialog {
    background: white;
    padding: 25px;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.brixzly-confirm-dialog p {
    margin: 0 0 20px 0;
    font-size: 15px;
    line-height: 1.5;
    color: #333;
}

.brixzly-confirm-dialog > div {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

#brixzly-rfp-mailbox-container {
    margin: 20px 0;
}

/* Loading state */
.mailbox-loading {
    text-align: center;
    padding: 40px;
    font-size: 16px;
    color: #666;
}

/* Error state */
.mailbox-error {
    background: #fff;
    border-left: 4px solid #dc3232;
    padding: 12px;
    margin: 20px 0;
    border-radius: 4px;
}

.mailbox-error .error-message {
    color: #dc3232;
    font-weight: 600;
}

/* Email list view */
.mailbox-email-list {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.mailbox-header {
    padding: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 15px;
}

.mailbox-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.mailbox-email-address {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mailbox-email-address .label {
    font-weight: 600;
    color: #555;
}

.mailbox-email-address .value {
    color: #2271b1;
    font-family: monospace;
    font-size: 14px;
}

/* Email list */
.emails-list {
    max-height: 600px;
    overflow-y: auto;
}

.email-item {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f1;
    cursor: pointer;
    transition: background-color 0.2s;
}

.email-item:hover {
    background-color: #f6f7f7;
}

.email-item:last-child {
    border-bottom: none;
}

.email-item-header {
    display: grid;
    grid-template-columns: auto 200px 1fr auto auto auto;
    gap: 15px;
    align-items: center;
}

/* Mark as Spam button in list view */
.mark-as-spam-list-btn {
    grid-column: -1; /* Place at the end */
    justify-self: end;
}

/* Spam email items - use flexbox for better layout */
.spam-email-item .email-item-header {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.spam-email-item .email-item-info {
    flex: 1;
    min-width: 0; /* Allow text to wrap */
}

.spam-email-item .email-item-actions {
    flex-shrink: 0;
    margin-left: auto;
}

.email-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    margin: 0;
    accent-color: #2271b1;
}

.email-sender {
    font-size: 14px;
    color: #646970;
}

.email-sender-name {
    cursor: help;
}

.email-sender-email {
    font-size: 12px;
    color: #8c8f94;
    margin-left: 2px;
}

.email-detail-from-name {
    cursor: help;
}

.email-detail-from-email {
    font-size: 16px;
    color: #646970;
    margin-left: 2px;
}

.email-detail-cc-name {
    cursor: help;
}

.email-detail-cc-email {
    font-size: 16px;
    color: #646970;
    margin-left: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-subject {
    font-weight: 600;
    font-size: 15px;
    color: #1d2327;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-date {
    font-size: 13px;
    color: #646970;
    white-space: nowrap;
    text-align: right;
}

.email-size {
    font-size: 13px;
    color: #646970;
    white-space: nowrap;
    text-align: right;
}

/* Empty state */
.empty-state {
    padding: 60px 20px;
    text-align: center;
    color: #646970;
}

.empty-state p {
    font-size: 16px;
    margin: 0;
}

/* Pagination */
.mailbox-pagination {
    padding: 15px 20px;
    border-top: 1px solid #f0f0f1;
    background: #f6f7f7;
}

.pagination-nav {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: center;
}

.page-info {
    color: #646970;
    font-size: 14px;
}

/* Email detail view */
.mailbox-email-detail {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.email-detail-header {
    padding: 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    gap: 15px;
}

.email-detail-header h2 {
    margin: 0;
    font-size: 23px;
    font-weight: 400;
    flex: 1;
}

.email-detail-actions {
    padding: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f9f9f9;
}

#email-detail-subject {
    margin: 0;
    font-size: 23px;
    font-weight: 400;
}

.email-detail-meta {
    padding: 20px;
    border-bottom: 1px solid #f0f0f1;
    background: #f6f7f7;
}

.email-meta-row {
    display: flex;
    margin-bottom: 10px;
    font-size: 14px;
}

.email-meta-row:last-child {
    margin-bottom: 0;
}

.email-meta-row .label {
    font-weight: 600;
    color: #555;
    min-width: 60px;
    margin-right: 10px;
}

.email-meta-row .value {
    color: #1d2327;
    flex: 1;
}

.email-detail-body {
    padding: 20px;
    min-height: 200px;
    font-size: 18px;
}

.email-detail-body pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #1d2327;
}

.email-detail-body img {
    max-width: 100%;
    height: auto;
}

/* Inline Reply Form (Gmail-style) */
.reply-form-container {
    margin-top: 20px;
    border-top: 1px solid #ddd;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 4px;
}

.reply-form-header {
    padding: 0 0px 15px 0px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.reply-form-header h4 {
    margin: 0;
}

.reply-form-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
}

.reply-close-btn {
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #fff;
    background: #2271b1;
    padding: 6px 12px;
    border-radius: 4px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    transition: background-color 0.2s;
}

.reply-close-btn:hover {
    background: #135e96;
    color: #fff;
}

#reply-form {
    padding: 0 20px 20px 20px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

.reply-form-field {
    margin-bottom: 15px;
}

.reply-form-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #1d2327;
    font-size: 13px;
}

.reply-cc-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.reply-cc-input-wrapper input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    background: #fff;
}

.reply-cc-input-wrapper button {
    flex-shrink: 0;
    padding: 8px 12px;
    min-width: 40px;
}

.reply-form-field input[type="text"] {
    width: 100%;
    max-width: 100%;
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    background: #fff;
}

.reply-form-field input[readonly] {
    background-color: #f6f7f7;
    color: #646970;
    cursor: not-allowed;
}

.reply-form-field textarea {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    resize: vertical;
    min-height: 150px;
    background: #fff;
}

.reply-form-field input[readonly] {
    background-color: #f6f7f7;
    color: #646970;
}

.reply-form-field textarea {
    resize: vertical;
    min-height: 200px;
}

.reply-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 15px;
}

/* Reply Attachments */
.reply-form-field #reply-attachments {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s;
}

.reply-form-field #reply-attachments:hover {
    border-color: #2271b1;
}

.reply-form-field #reply-attachments:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.reply-attachments-list {
    margin-top: 12px;
}

.reply-attachments-list > div {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reply-attachment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.2s;
}

.reply-attachment-item:hover {
    border-color: #8c8f94;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.reply-attachment-item span {
    flex: 1;
    font-size: 14px;
    color: #1d2327;
    display: flex;
    align-items: center;
    gap: 8px;
}

.reply-attachment-item span::before {
    content: "📎";
    font-size: 16px;
}

.reply-attachment-item button {
    background: #d63638;
    color: #fff;
    border: none;
    border-radius: 3px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    padding: 0;
    margin-left: 10px;
}

.reply-attachment-item button:hover {
    background: #b32d2e;
}

.reply-attachment-item button:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(214, 54, 56, 0.3);
}

/* WYSIWYG Editor */
.reply-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 8px;
    background: #f6f7f7;
    border: 1px solid #8c8f94;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
}

.editor-btn {
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #8c8f94;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
    color: #2c3338;
    transition: all 0.2s;
    min-width: 32px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.editor-btn:hover {
    background: #f0f0f1;
    border-color: #2271b1;
}

.editor-btn:active {
    background: #e0e0e0;
}

.toolbar-separator {
    width: 1px;
    height: 20px;
    background: #8c8f94;
    margin: 0 5px;
}

.editor-select {
    padding: 5px 8px;
    border: 1px solid #8c8f94;
    border-radius: 3px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
    color: #2c3338;
    transition: all 0.2s;
    height: 28px;
    min-width: 80px;
}

.editor-select:hover {
    background: #f0f0f1;
    border-color: #2271b1;
}

.editor-select:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.editor-color {
    width: 40px;
    height: 28px;
    padding: 2px;
    border: 1px solid #8c8f94;
    border-radius: 3px;
    cursor: pointer;
    background: #fff;
    transition: all 0.2s;
}

.editor-color:hover {
    border-color: #2271b1;
}

.editor-color:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.reply-message-editor {
    min-height: 300px;
    max-height: 600px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid #8c8f94;
    border-radius: 0 0 4px 4px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    background: #fff;
    color: #1d2327;
    outline: none;
}

.reply-message-editor:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.reply-message-editor:empty:before {
    content: attr(placeholder);
    color: #8c8f94;
    pointer-events: none;
}

.reply-message-editor p {
    margin: 0 0 1em 0;
}

.reply-message-editor p:last-child {
    margin-bottom: 0;
}

.reply-message-editor .thread-email-block {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* Thread View in Reply Form (Gmail-style) - DEPRECATED */
.reply-thread-view {
    margin-top: 20px;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 500px;
    overflow-y: auto;
}

.reply-thread-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

.reply-thread-content {
    position: relative;
}

.thread-email-item {
    transition: background-color 0.2s;
}

.thread-email-item:hover {
    background-color: #f5f5f5 !important;
}

.thread-email-response-area {
    transition: all 0.2s;
}

.thread-email-respond {
    transition: all 0.2s;
}

.thread-email-respond:hover {
    background: #135e96 !important;
}

.thread-response-textarea {
    transition: border-color 0.2s;
}

.thread-response-textarea:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

/* Thread Toggle Button */
.thread-toggle-btn {
    transition: all 0.2s;
    border-radius: 4px;
    font-size: 24px !important;
    padding: 8px 12px !important;
    min-width: 40px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.thread-toggle-btn:hover {
    background: #f0f0f1 !important;
    color: #2271b1 !important;
}

.email-thread-content {
    margin-top: 10px;
}

/* Address Book Modal for CC */
#address-book-cc-modal {
    z-index: 999999 !important;
}

#address-book-cc-modal .brixzly-rfp-modal-content {
    z-index: 1000000 !important;
}

/* Address Book detail panel - disable pointer events when not active to prevent blocking sidebar clicks */
/* This is the main issue: the detail panel covers the entire viewport even when hidden */
.brixzly-ab-detail-panel:not(.active) {
    pointer-events: none !important;
}

.brixzly-ab-detail-panel.active {
    pointer-events: auto !important;
}

/* Address Book modals - ensure they escape stacking contexts and appear above everything */
/* The issue: modals are rendered inside .brixzly-rfp-list-view which has position:relative; z-index:1 */
/* This creates a stacking context that can constrain even position:fixed elements */
.brixzly-ab-modal,
#brixzly-ab-modal {
    /* Use a very high z-index to escape all stacking contexts */
    z-index: 999999 !important;
    position: fixed !important;
    /* Ensure it's not constrained by parent transforms/stacking contexts */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
}

.brixzly-ab-detail-panel {
    /* Use a very high z-index to escape all stacking contexts */
    z-index: 999998 !important;
    position: fixed !important;
    /* Ensure it's not constrained by parent transforms/stacking contexts */
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
}

.brixzly-ab-modal-content {
    position: relative !important;
    z-index: 1 !important;
}

.brixzly-ab-detail-panel-content {
    position: relative !important;
    z-index: 1 !important;
}

/* Address Book Modal Checkboxes - Make them larger */
.address-book-cc-contact,
.address-book-contact {
    width: 24px !important;
    height: 24px !important;
    cursor: pointer;
    margin-right: 12px !important;
    accent-color: #2271b1;
    flex-shrink: 0;
}

.email-detail-header {
    display: flex;
    align-items: center;
    gap: 15px;
}

.email-detail-actions {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

/* Responsive */
@media screen and (max-width: 782px) {
    .brixzly-rfp-layout {
        flex-direction: column;
    }
    
    .brixzly-rfp-sidebar {
        width: 100%;
    }
    
    .mailbox-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .email-item-header {
        grid-template-columns: auto 1fr;
        gap: 5px;
    }
    
/* Standalone Messages Interface */
.brixzly-rfp-messages-standalone {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.brixzly-rfp-messages-standalone .brixzly-rfp-container {
    width: 100%;
}

.brixzly-rfp-messages-standalone .brixzly-rfp-messages-view {
    display: block !important;
}

    .email-date {
        text-align: left;
    }
    
    .email-size {
        text-align: left;
    }
}

/* Save to File Manager button for attachments */
.email-attachments .save-to-file-manager-btn {
    margin-left: 30px !important;
}

.brixzly-rfp-btn.brixzly-rfp-btn-primary.save-to-file-manager-btn {
    margin-left: 30px !important;
}
