/* ==========================================================================
   BrightDocs Email Styles
   Shared styles for EmailViewer (modal) and EmailClient (full page)
   ========================================================================== */

/* ==========================================================================
   CSS Variables (email-specific)
   ========================================================================== */

:root {
    --email-sidebar-width: 280px;
    --email-list-width: 380px;
    --email-unread-color: #1a73e8;
    --email-unread-bg: #e8f0fe;
    --email-selected-bg: #e8f0fe;
    --email-hover-bg: #f5f5f5;
    --email-border-color: #e0e0e0;
    --email-attachment-bg: #f8f9fa;
}

/* ==========================================================================
   Email Viewer Modal
   ========================================================================== */

#emailViewerModal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

#emailViewerModal .modal-content {
    position: relative;
    background: #fff;
    margin: 2% auto;
    width: 90%;
    max-width: 900px;
    height: 90%;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Modal Header */
.email-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.email-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.email-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.email-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Modal Body */
.email-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Modal Footer */
.email-modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--email-border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.email-modal-footer .btn-link {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.email-modal-footer .btn-link:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Email Detail View (shared between modal and full page)
   ========================================================================== */

.email-detail {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    min-width: 0;
}

.email-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    text-align: center;
    padding: 40px;
}

.email-detail-empty .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.email-detail-empty h3 {
    margin: 0 0 8px 0;
    color: #666;
}

.email-detail-empty p {
    margin: 0;
    font-size: 14px;
}

/* Email Header */
.email-detail-header {
    padding: 20px;
    border-bottom: 1px solid var(--email-border-color);
    background: #fff;
}

.email-subject {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: #202124;
    line-height: 1.4;
}

.email-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 14px;
    color: #5f6368;
}

.email-meta-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}

.email-meta-label {
    font-weight: 500;
    color: #202124;
    min-width: 50px;
}

.email-meta-value {
    flex: 1;
}

.email-account-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: #e8f0fe;
    color: #1a73e8;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.email-date {
    color: #5f6368;
    font-size: 13px;
    margin-left: auto;
}

/* Email Actions Toolbar */
.email-actions-toolbar {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--email-border-color);
    background: #f8f9fa;
    flex-wrap: wrap;
}

.email-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: white;
    border: 1px solid #dadce0;
    border-radius: 6px;
    font-size: 13px;
    color: #5f6368;
    cursor: pointer;
    transition: all 0.2s;
}

.email-action-btn:hover {
    background: #f1f3f4;
    border-color: #c6c6c6;
    color: #202124;
}

.email-action-btn.primary {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.email-action-btn.primary:hover {
    background: #5a6fd6;
    border-color: #5a6fd6;
}

.email-action-btn.danger {
    color: #d93025;
}

.email-action-btn.danger:hover {
    background: #fce8e6;
    border-color: #f5c6cb;
}

/* Email Body */


/* HTML Email Body */
.email-body-html {
    font-size: 14px;
    line-height: 1.6;
    color: #202124;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* =============================================================================
   CRITICAL: Force table elements to render as tables
   This overrides inline styles like style="display: block" on <td> elements
   ============================================================================= */

.email-body-html table {
    display: table !important;
    border-collapse: collapse;
    max-width: 100%;
}

.email-body-html tbody {
    display: table-row-group !important;
}

.email-body-html thead {
    display: table-header-group !important;
}

.email-body-html tfoot {
    display: table-footer-group !important;
}

.email-body-html tr {
    display: table-row !important;
}

.email-body-html td,
.email-body-html th {
    display: table-cell !important;
    vertical-align: top;
}

.email-body-html colgroup {
    display: table-column-group !important;
}

.email-body-html col {
    display: table-column !important;
}

/* Images shouldn't overflow */
.email-body-html img {
    max-width: 100%;
    height: auto;
}

/* Plain text emails */
.email-body-text {
    font-size: 14px;
    line-height: 1.6;
    color: #202124;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    margin: 0;
}

/* Ensure parent containers don't squeeze content */
.email-detail-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    min-width: 0;
}

/* ==========================================================================
   Attachments Section
   ========================================================================== */

.email-attachments-section {
    border-top: 1px solid var(--email-border-color);
    padding: 16px 20px;
    background: #f8f9fa;
}

.email-attachments-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #202124;
}

.email-attachments-header .count {
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.email-attachments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.email-attachment-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border: 1px solid var(--email-border-color);
    border-radius: 8px;
    transition: all 0.2s;
}

.email-attachment-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.attachment-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.attachment-info {
    flex: 1;
    min-width: 0;
}

.attachment-filename {
    font-weight: 500;
    color: #202124;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-meta {
    font-size: 12px;
    color: #5f6368;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
}

.attachment-status {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.attachment-status.pending {
    background: #fff3cd;
    color: #856404;
}

.attachment-status.completed {
    background: #d4edda;
    color: #155724;
}

.attachment-status.failed {
    background: #f8d7da;
    color: #721c24;
}

.attachment-status.skipped {
    background: #e2e3e5;
    color: #6c757d;
}

.attachment-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.attachment-action-btn {
    padding: 6px 10px;
    font-size: 12px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    background: white;
    color: #5f6368;
    cursor: pointer;
    transition: all 0.2s;
}

.attachment-action-btn:hover {
    background: #f1f3f4;
    color: #202124;
}

.attachment-action-btn.primary {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.attachment-action-btn.primary:hover {
    background: #5a6fd6;
}

/* ==========================================================================
   Related Documents Section
   ========================================================================== */

.email-related-docs {
    border-top: 1px solid var(--email-border-color);
    padding: 16px 20px;
    background: #fff;
}

.email-related-docs-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    color: #202124;
}

.related-doc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.related-doc-item:hover {
    background: #e8f0fe;
}

.related-doc-icon {
    font-size: 20px;
}

.related-doc-info {
    flex: 1;
    min-width: 0;
}

.related-doc-name {
    font-weight: 500;
    color: #202124;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.related-doc-meta {
    font-size: 12px;
    color: #5f6368;
}

/* ==========================================================================
   Email Client Full Page Layout
   ========================================================================== */

.email-client-container {
    display: flex;
    height: calc(100vh - 80px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Sidebar (Folders) */
.email-sidebar {
    width: var(--email-sidebar-width);
    background: #f8f9fa;
    border-right: 1px solid var(--email-border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.email-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--email-border-color);
}

.email-compose-btn {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.email-compose-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Folder List */
.email-folders {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

.email-folder-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.15s;
    color: #5f6368;
    font-size: 14px;
}

.email-folder-item:hover {
    background: #e8eaed;
}

.email-folder-item.active {
    background: var(--email-unread-bg);
    color: var(--email-unread-color);
    font-weight: 600;
}

.email-folder-item .folder-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.email-folder-item .folder-name {
    flex: 1;
}

.email-folder-item .folder-count {
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.email-folder-item.active .folder-count {
    background: var(--email-unread-color);
}

/* Account Filter */
.email-account-filter {
    padding: 12px 16px;
    border-top: 1px solid var(--email-border-color);
}

.email-account-filter label {
    display: block;
    font-size: 12px;
    color: #5f6368;
    margin-bottom: 6px;
    font-weight: 500;
}

.email-account-filter select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #dadce0;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}

/* Email List Pane */
.email-list-pane {
    width: var(--email-list-width);
    border-right: 1px solid var(--email-border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.email-list-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--email-border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
}

.email-search-box {
    flex: 1;
    position: relative;
}

.email-search-box input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid #dadce0;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s;
}

.email-search-box input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.email-search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #5f6368;
    font-size: 14px;
}

.email-bulk-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.email-select-all {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.email-bulk-btn {
    padding: 6px 10px;
    font-size: 12px;
    border: 1px solid #dadce0;
    border-radius: 4px;
    background: white;
    color: #5f6368;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.email-bulk-btn:hover {
    background: #f1f3f4;
}

.email-bulk-btn.danger,
.email-bulk-btn[style*="color: #dc3545"] {
    color: #dc3545;
}

/* Email List */
.email-list {
    flex: 1;
    overflow-y: auto;
}

.email-list-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f3f4;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
}

.email-list-item:hover {
    background: var(--email-hover-bg);
}

.email-list-item.selected {
    background: var(--email-selected-bg);
}

.email-list-item.unread {
    background: #fff;
}

.email-list-item.unread .email-item-sender,
.email-list-item.unread .email-item-subject {
    font-weight: 600;
}

.email-list-item.unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--email-unread-color);
}

.email-item-checkbox {
    flex-shrink: 0;
    margin-top: 2px;
}

.email-item-checkbox input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.email-item-content {
    flex: 1;
    min-width: 0;
}

.email-item-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.email-item-sender {
    font-size: 14px;
    color: #202124;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.email-item-date {
    font-size: 12px;
    color: #5f6368;
    flex-shrink: 0;
}

.email-item-subject {
    font-size: 13px;
    color: #202124;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.email-item-preview {
    font-size: 12px;
    color: #5f6368;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-item-indicators {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.email-item-indicators .indicator {
    font-size: 12px;
}

.email-item-account {
    font-size: 10px;
    padding: 2px 6px;
    background: #e8f0fe;
    color: #1a73e8;
    border-radius: 8px;
}

/* ==========================================================================
   Email Compose Modal - UPDATED: Larger & Resizable
   ========================================================================== */

#emailComposeModal {
    display: none;
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow-y: auto;
}

#emailComposeModal .compose-content {
    position: relative;
    margin: 5vh auto;
    width: 700px;
    max-width: calc(100vw - 40px);
    min-width: 400px;
    height: 80vh;
    max-height: calc(100vh - 40px);
    min-height: 400px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Resize handle */
.compose-resize-handle {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #94a3b8;
    user-select: none;
    border-radius: 4px;
    z-index: 10;
}

.compose-resize-handle:hover {
    background: #e2e8f0;
    color: #64748b;
}

.compose-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #404040;
    color: white;
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.compose-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
}

.compose-header-actions {
    display: flex;
    gap: 8px;
}

.compose-header-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.compose-header-btn:hover {
    opacity: 1;
}

.compose-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
}

.compose-field {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid #f1f3f4;
    flex-shrink: 0;
}

.compose-field label {
    width: 60px;
    font-size: 13px;
    color: #5f6368;
}

.compose-field input,
.compose-field select {
    flex: 1;
    border: none;
    padding: 6px 0;
    font-size: 14px;
    outline: none;
}

.compose-field select {
    background: transparent;
    cursor: pointer;
}

.compose-subject {
    padding: 8px 16px;
    border-bottom: 1px solid #f1f3f4;
    flex-shrink: 0;
}

.compose-subject input {
    width: 100%;
    border: none;
    font-size: 14px;
    outline: none;
    padding: 6px 0;
}

.compose-editor {
    flex: 1;
    min-height: 150px;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.compose-editor textarea {
    flex: 1;
    width: 100%;
    min-height: 120px;
    border: none;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    font-family: inherit;
}

.compose-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid #f1f3f4;
    background: #f8f9fa;
    flex-shrink: 0;
}

.compose-send-btn {
    padding: 10px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.compose-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.compose-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.compose-discard-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #dadce0;
    border-radius: 6px;
    font-size: 13px;
    color: #5f6368;
    cursor: pointer;
    transition: all 0.2s;
}

.compose-discard-btn:hover {
    background: #f1f3f4;
}

/* ==========================================================================
   Compose Attachments (Forwarding)
   ========================================================================== */

#composeAttachments {
    margin: 0.5rem 1rem;
    display: none;
}

.compose-attachments-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.compose-attachments-header {
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
    margin-bottom: 0.5rem;
}

.compose-attachment-item {
    padding: 0.25rem 0;
}

.compose-attachment-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #334155;
}

.compose-attachment-label:hover {
    color: #1e40af;
}

.compose-attachment-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.compose-attachment-label .att-icon {
    font-size: 1rem;
}

.compose-attachment-label .att-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compose-attachment-label .att-size {
    color: #94a3b8;
    font-size: 0.75rem;
}

/* ==========================================================================
   HTML Preview for Forwarding/Replying
   ========================================================================== */

#composeHtmlPreview {
    margin: 0.5rem 1rem;
    display: none;
    flex-shrink: 0;
    max-height: 300px;
    overflow: hidden;
}

.compose-html-preview-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.compose-html-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #f1f5f9;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: #475569;
    user-select: none;
    flex-shrink: 0;
}

.compose-html-preview-header:hover {
    background: #e2e8f0;
}

.compose-html-preview-header .toggle-icon {
    font-size: 0.75rem;
    color: #94a3b8;
}

.compose-html-preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    border-top: 1px solid #e2e8f0;
    background: white;
    max-height: 250px;
}

.compose-html-preview-content .email-body-html {
    font-size: 0.875rem;
}

.compose-html-preview-content .email-body-html img {
    max-width: 100%;
    height: auto;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.email-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #5f6368;
}

.email-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f1f3f4;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 12px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Empty States
   ========================================================================== */

.email-list-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: #5f6368;
}

.email-list-empty .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.email-list-empty h4 {
    margin: 0 0 4px 0;
    color: #202124;
}

.email-list-empty p {
    margin: 0;
    font-size: 13px;
}

/* ==========================================================================
   Nav Badge for Unread Count
   ========================================================================== */

.nav-email-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #d93025;
    color: white;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 6px;
}

.nav-email-badge.hidden {
    display: none;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 1200px) {
    .email-client-container {
        height: calc(100vh - 60px);
    }

    .email-sidebar {
        width: 220px;
    }

    .email-list-pane {
        width: 320px;
    }
}


/* ==========================================================================
   EMAIL IFRAME ISOLATION
   ========================================================================== */

/* Email body iframe - isolated container for HTML emails */
.email-body-iframe {
    width: 100%;
    height: 500px;
    min-height: 300px;
    border: none;
    background: white;
    display: block;
}

/* Ensure the container allows iframe to fill properly */
.email-body-container {
    flex: 1;
    overflow: auto;
    padding: 0;
    background: #fff;
    min-width: 0;
    width: 100%;
}

/* When iframe is present, let it fill the container */
.email-body-container:has(.email-body-iframe) {
    padding: 0;
    overflow: hidden;
}

/* Plain text emails still get padding */
.email-body-container .email-body-text {
    padding: 20px;
}


/* ==========================================================================
   Gmail Labels
   ========================================================================== */
.email-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

/* Labels inline with To: row */
.email-meta-row.with-labels {
    align-items: center !important;
}

.email-meta-row.with-labels .email-labels {
    margin-left: auto;
    margin-top: -2px;
}

.email-label-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    background: #e8eaed;
    color: #3c4043;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

/* Gmail category colors */
.email-label-tag.label-primary {
    background: #d3e3fd;
    color: #1967d2;
}

.email-label-tag.label-social {
    background: #fce8e6;
    color: #c5221f;
}

.email-label-tag.label-promotions {
    background: #e6f4ea;
    color: #137333;
}

.email-label-tag.label-updates {
    background: #fef7e0;
    color: #b06000;
}

.email-label-tag.label-forums {
    background: #f3e8fd;
    color: #8430ce;
}

.email-label-tag.label-important {
    background: #fce8e6;
    color: #c5221f;
}

.email-label-tag.label-starred {
    background: #fef7e0;
    color: #b06000;
}


@media (max-width: 900px) {
    .email-client-container {
        flex-direction: column;
    }

    .email-sidebar {
        width: 100%;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--email-border-color);
    }

    .email-folders {
        display: flex;
        padding: 0;
        overflow-x: auto;
    }

    .email-folder-item {
        padding: 12px 16px;
        white-space: nowrap;
    }

    .email-list-pane {
        width: 100%;
        max-height: 40vh;
    }

    #emailComposeModal .compose-content {
        width: calc(100% - 40px);
        height: 70vh;
        margin: 5vh auto;
        min-width: unset;
    }

    /* ==========================================================================
   Scrollbar Stability - Prevent layout shift when scrollbar appears
   ========================================================================== */
    .email-detail-pane,
    .email-body-container,
    .email-list {
        scrollbar-gutter: stable;
    }


}

@media (max-width: 600px) {
    #emailComposeModal .compose-content {
        width: 100%;
        height: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
    }
}