/* ================================================================
   Mail Syncfusion Layout - Three Panel Design
   ================================================================ */

/* Toolbar */
.mail-toolbar {
    background: white;
    border-bottom: 1px solid #e1e4e8;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.mail-toolbar .e-toolbar-item .e-tbar-btn {
    font-size: 13px;
}

.mail-search-box {
    min-width: 200px;
}

/* Splitter Layout */
.mail-splitter {
    border: none;
}

.mail-splitter .e-split-bar {
    background: #e1e4e8;
}

/* Folder Panel */
.folder-panel {
    background: #f8f9fa;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.folder-header {
    background: white;
    flex-shrink: 0;
}

.account-dropdown {
    width: 100%;
}

/* Folder Tree */
.mail-folder-tree {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.mail-folder-tree .e-list-text {
    font-size: 13px;
}

.mail-folder-tree .e-list-item.e-active {
    background: #e8f0fe;
    color: #1a73e8;
}

.mail-folder-tree .e-list-item:hover {
    background: #f0f0f0;
}

.mail-folder-tree .e-list-icon {
    font-size: 16px;
    margin-right: 8px;
}

/* Message List Panel */
.message-list-panel {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

.message-list-header {
    flex-shrink: 0;
    background: white;
}

/* Message Grid */
.mail-message-grid {
    flex: 1;
    overflow: hidden;
}

.mail-message-grid .e-gridheader {
    display: none;
}

.mail-message-grid .e-row {
    cursor: pointer;
    transition: background-color 0.15s;
}

.mail-message-grid .e-row:hover {
    background-color: #f6f8fa !important;
}

.mail-message-grid .e-row.e-active {
    background-color: #e8f0fe !important;
}

.mail-message-grid .e-rowcell {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: middle;
}

/* Avatar */
.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #dde3ea;
    color: #495057;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-sm.avatar-unread {
    background: #1a73e8;
    color: white;
}

.avatar-large {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #1a73e8;
    color: white;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Reading Pane */
.reading-pane-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

.reading-pane-header {
    flex-shrink: 0;
    background: white;
}

.reading-pane-header h5 {
    font-size: 18px;
    font-weight: 600;
    color: #24292e;
}

.attachments-bar {
    flex-shrink: 0;
}

.attachment-chip {
    border-radius: 16px;
    font-size: 12px;
    padding: 2px 10px;
}

.attachment-chip:hover {
    background: #e8f0fe;
    border-color: #1a73e8;
}

/* Mail Body Tabs */
.mail-body-tabs {
    flex: 1;
    overflow: hidden;
}

.mail-body-tabs .e-tab-header {
    border-bottom: 1px solid #e1e4e8;
    background: #f8f9fa;
}

.reading-pane-body {
    flex: 1;
    overflow-y: auto;
}

.html-body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #24292e;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.html-body img {
    max-width: 100%;
    height: auto;
}

.html-body a {
    color: #1a73e8;
}

.html-body blockquote {
    border-left: 3px solid #dfe2e5;
    padding-left: 12px;
    color: #6a737d;
    margin-left: 0;
}

.plain-text-body {
    font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    color: #24292e;
    background: transparent;
    border: none;
}

/* Compose Dialog */
.compose-dialog .e-dlg-header-content {
    background: #f8f9fa;
    border-bottom: 1px solid #e1e4e8;
}

.compose-dialog .compose-form .form-label {
    font-size: 13px;
    margin-bottom: 4px;
}

.compose-dialog .compose-form .e-richtexteditor {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    border-radius: 4px;
}

.compose-dialog .compose-form .e-rte-content .e-content {
    min-height: 200px;
}

.compose-dialog .compose-attachments .badge {
    font-size: 12px;
    font-weight: 500;
}

.compose-dialog .compose-validation-error {
    color: #dc3545;
    font-size: 13px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Signature Editor */
.signature-editor {
    padding: 16px;
    background: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
}

.signature-editor h6 {
    color: #0078d4;
    font-size: 14px;
}

.signature-editor .e-richtexteditor {
    font-size: 13px;
}

.signature-editor .signature-preview {
    font-size: 13px;
    line-height: 1.5;
    color: #333;
}

/* Folder Unread Badge */
.folder-node-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-right: 4px;
}

.folder-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    border-radius: 10px;
    background: #1a73e8;
    color: white;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

/* Blocked Image Placeholder */
.blocked-image {
    display: inline-block;
    padding: 4px 8px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    font-size: 12px;
}

.external-images-bar {
    font-size: 13px;
}

/* Toast Notification Override */
.e-toast-container {
    z-index: 100001 !important;
}

.e-toast-success .e-toast-icon {
    color: #198754;
}

.e-toast-danger .e-toast-icon {
    color: #dc3545;
}

.e-toast-warning .e-toast-icon {
    color: #ffc107;
}

.e-toast-info .e-toast-icon {
    color: #0d6efd;
}

/* Delete Confirmation Dialog */
.delete-confirm-dialog .e-dlg-header-content {
    background: #fff3cd;
    border-bottom: 1px solid #ffc107;
}

.delete-confirm-dialog .e-danger {
    background: #dc3545 !important;
    border-color: #dc3545 !important;
    color: white !important;
}

/* Full Message View Dialog */
.full-message-dialog .e-dlg-content {
    padding: 0;
    overflow-y: auto;
}

/* Loading State in Folder Panel */
.folder-panel .spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .mail-splitter .e-pane.folder-pane {
        min-width: 180px;
    }
}

@media (max-width: 992px) {
    .mail-splitter .e-pane.reading-pane {
        min-width: 300px;
    }

    .message-list-header h6 {
        font-size: 13px;
    }
}

@media (max-width: 768px) {
    .mail-toolbar .e-toolbar-item .e-tbar-btn-text {
        display: none;
    }

    .mail-toolbar .e-toolbar-item .e-tbar-btn {
        padding: 4px 8px;
    }

    .mail-search-box {
        min-width: 140px;
    }
}

/* ================================================================
   Threading & Conversation View
   ================================================================ */

/* View mode toggle */
.view-mode-toggle .btn {
    padding: 2px 8px;
    font-size: 14px;
    line-height: 1.4;
}

/* Thread grid */
.mail-thread-grid {
    border: none;
}

.mail-thread-grid .e-gridheader {
    display: none;
}

.mail-thread-grid .e-row {
    cursor: pointer;
}

.mail-thread-grid .e-row:hover {
    background-color: #f0f6ff;
}

.mail-thread-grid .e-row.e-active {
    background-color: #e3f0ff;
}

.thread-count-badge {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 10px;
    vertical-align: middle;
}

/* Conversation reading pane */
.conversation-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.conversation-messages {
    flex: 1;
    overflow-y: auto;
}

.conversation-message-card {
    transition: background-color 0.15s ease;
}

.conversation-message-card:hover {
    background-color: #fafafa;
}

.conversation-unread {
    background-color: #f0f6ff;
    border-left: 3px solid #0078d4;
}

.conversation-message-header {
    cursor: pointer;
    user-select: none;
}

.conversation-message-body {
    border-top: 1px solid #eee;
    margin-left: 48px;
}

.conversation-message-body .html-body {
    max-height: 400px;
    overflow-y: auto;
}

/* Advanced Search Panel */
.advanced-search-panel {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.advanced-search-panel .form-label {
    color: #495057;
    font-weight: 500;
}

.advanced-search-input {
    font-size: 13px;
}

/* Error state for advanced-search date inputs */
.advanced-search-input.is-invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

.advanced-search-check {
    font-size: 13px;
}

/* Badge shown in message-list header when search results are active */
.search-mode-badge {
    font-size: 11px;
    padding: 3px 7px;
    border-radius: 10px;
    background-color: #0dcaf0 !important;
    color: #000 !important;
    cursor: default;
}

/* Per-message action buttons in expanded conversation thread card */
.conversation-message-actions .btn {
    font-size: 12px;
    padding: 2px 8px;
}

.cursor-pointer {
    cursor: pointer;
}

/* ============================================================
   Context Menu (right-click menus for messages and folders)
   ============================================================ */

/* Transparent full-screen backdrop to dismiss context menus on outside click */
.context-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 9998;
    cursor: default;
}

/* Positioned context menu panel */
.mail-context-menu {
    position: fixed;
    z-index: 9999;
    min-width: 200px;
    animation: contextMenuFadeIn 80ms ease-out;
}

.mail-context-menu .dropdown-menu {
    display: block;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 6px;
    font-size: 13px;
}

.mail-context-menu .dropdown-item {
    padding: 6px 14px;
    border-radius: 4px;
    margin: 1px 4px;
    width: calc(100% - 8px);
}

.mail-context-menu .dropdown-item:focus {
    outline: none;
}

.mail-context-menu .dropdown-header {
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    padding: 4px 14px 2px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.mail-context-menu .dropdown-divider {
    margin: 3px 8px;
}

@keyframes contextMenuFadeIn {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}

/* Bulk actions toolbar */
.bulk-actions-bar {
    border-radius: 0;
    font-size: 13px;
}
