/* ========================================
   NINJAMAIL — EMAIL INBOX STYLES
   Unified inbox layout and components
   ======================================== */

/* ===== EMAIL SECTION — FULL BLEED ===== */
#section-email.app-section {
    padding: 0;
    max-width: 100%;
    flex-direction: column;
    height: calc(100vh - 49px); /* topbar: 36px min-height + 6px*2 padding + 1px border */
    overflow: hidden;
}

#section-email.app-section.active {
    display: flex;
}

#section-email.app-section:not(.active) {
    display: none;
}

#section-email .section-header-bar {
    display: none;
}

#section-email .email-section-tabs {
    padding: 0 12px;
    flex-shrink: 0;
}

#section-email .email-tab {
    padding: 10px 14px;
}

#section-email .email-tab-content {
    flex: 1;
    overflow: hidden;
}

#section-email .email-tab-content.active {
    display: flex;
    flex-direction: column;
}

#section-email #emailTabInbox.email-tab-content {
    padding: 0;
}

#section-email .email-tab-content:not(#emailTabInbox) {
    padding: var(--spacing-lg);
    overflow-y: auto;
}

#section-email #emailTabInbox {
    flex: 1;
    overflow: hidden;
}

#section-email #inboxContainer {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Resend stats — compact inline in tabs bar */
.email-tabs-wrapper {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-card);
    flex-shrink: 0;
}

.email-tabs-wrapper .email-section-tabs {
    flex: 1;
    border-bottom: none;
}

.email-usage-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    white-space: nowrap;
}

.email-usage-inline .usage-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.email-usage-inline .usage-stat .stat-value {
    font-weight: 700;
    color: var(--text-secondary);
}

.email-usage-inline .usage-bar {
    width: 40px;
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    overflow: hidden;
}

.email-usage-inline .usage-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s;
}

.email-usage-inline .plan-badge {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

/* ===== LAYOUT ===== */
.inbox-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    flex: 1;
    background: var(--bg-card);
    border-top: 1px solid var(--border-light);
    overflow: hidden;
}

/* ===== SIDEBAR ===== */
.inbox-sidebar {
    background: var(--bg-card);
    border-right: 1px solid var(--border-light);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.inbox-compose-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition:
        opacity 0.15s,
        transform 0.15s;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    font-family: inherit;
}

.inbox-compose-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.inbox-folders {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.inbox-folder-item {
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition:
        background 0.15s,
        color 0.15s;
}

.inbox-folder-item:hover {
    background: var(--bg-body);
}

.inbox-folder-item.active {
    background: #eef2ff;
    color: var(--primary);
    font-weight: 600;
}

.inbox-folder-label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}

.inbox-folder-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.inbox-folder-count {
    font-size: 11px;
    background: var(--bg-body);
    border-radius: 10px;
    padding: 2px 8px;
    color: var(--text-muted);
    font-weight: 600;
    flex-shrink: 0;
}

.inbox-folder-item.active .inbox-folder-count {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

/* ===== MAIN AREA ===== */
.inbox-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* ===== TOOLBAR ===== */
.inbox-toolbar {
    display: flex;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    gap: 8px;
    align-items: center;
}

.inbox-search {
    flex: 1;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.15s;
    outline: none;
}

.inbox-search:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.inbox-search::placeholder {
    color: var(--text-muted);
}

/* ===== SELECT ALL + BULK ACTIONS ===== */
.inbox-select-all {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}

.inbox-select-all input[type='checkbox'],
.inbox-thread-checkbox input[type='checkbox'] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #667eea;
    margin: 0;
}

.inbox-thread-checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.inbox-bulk-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.inbox-bulk-btn {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}

.inbox-bulk-btn:hover {
    border-color: #667eea;
    color: #667eea;
    background: #eef2ff;
}

.inbox-bulk-block {
    border-color: #ef4444;
    color: #ef4444;
}

.inbox-bulk-block:hover {
    background: #fef2f2;
    border-color: #dc2626;
    color: #dc2626;
}

.inbox-block-btn {
    font-size: 12px !important;
    opacity: 1 !important;
    color: #ef4444;
    border: 1px solid #fecaca !important;
    border-radius: 6px;
    padding: 4px 10px !important;
}

.inbox-block-btn:hover {
    background: #fef2f2 !important;
    color: #dc2626;
}

.inbox-bulk-count {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-left: 4px;
}

/* ===== THREAD LIST ===== */
.inbox-thread-list {
    flex: 1;
    overflow-y: auto;
}

.inbox-thread-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    display: grid;
    grid-template-columns: 24px 24px 180px 1fr auto;
    gap: 8px;
    align-items: center;
    transition: background 0.1s;
}

.inbox-thread-item.selected {
    background: #eef2ff;
}

.inbox-thread-item:hover {
    background: #f8fafc;
}

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

.inbox-thread-item.unread {
    font-weight: 600;
    border-left: 3px solid var(--primary);
}

/* ===== STAR BUTTON ===== */
.inbox-star-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    opacity: 0.3;
    padding: 0;
    line-height: 1;
    transition: opacity 0.15s;
    color: #d97706;
}

.inbox-star-btn:hover {
    opacity: 0.7;
}

.inbox-star-btn.active {
    opacity: 1;
}

/* ===== THREAD ITEM PARTS ===== */
.inbox-thread-sender {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.inbox-thread-content {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.inbox-thread-subject {
    font-size: 13px;
    color: var(--text-primary);
}

.inbox-thread-snippet {
    font-size: 12px;
    color: var(--text-muted);
}

.inbox-thread-meta {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
}

.inbox-thread-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.inbox-msg-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    background: var(--bg-body);
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

/* ===== BADGES ===== */
.inbox-badge {
    display: inline-flex;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.inbox-badge.campaign {
    background: #fef3c7;
    color: #b45309;
}

.inbox-badge.reply {
    background: #dbeafe;
    color: #1d4ed8;
}

/* Attachment styles */
.inbox-attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 8px;
}

.inbox-attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--bg-body, #f0f4f8);
    border-radius: 6px;
    font-size: 12px;
}

.inbox-attachment-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted, #94a3b8);
    font-size: 12px;
    padding: 0 2px;
}

.inbox-attach-btn {
    background: none;
    border: 1px solid var(--border-light, #e2e8f0);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    margin-right: 8px;
}

.inbox-attach-btn:hover {
    background: var(--bg-body, #f0f4f8);
}

.inbox-message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
    border-top: 1px solid var(--border-light, #e2e8f0);
    margin-top: 8px;
}

.inbox-attachment-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: var(--bg-body, #f0f4f8);
    border-radius: 6px;
    font-size: 12px;
    color: var(--primary, #2563eb);
    text-decoration: none;
}

.inbox-attachment-link:hover {
    background: #dbeafe;
}

/* Tab unread badge */
.inbox-count-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    line-height: 1;
}

/* ===== PAGINATION ===== */
.inbox-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-top: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-muted);
}

.inbox-page-btn {
    padding: 6px 14px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--bg-card);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.inbox-page-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.inbox-page-info {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== EMPTY STATE ===== */
.inbox-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.inbox-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.inbox-empty-text {
    font-size: 14px;
}

/* ===== LOADING STATE ===== */
.inbox-loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.inbox-loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-light);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: inboxSpin 0.8s linear infinite;
}

@keyframes inboxSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== THREAD DETAIL VIEW ===== */
.inbox-thread-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
}

.inbox-back-btn {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 6px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.15s;
    font-family: inherit;
}

.inbox-back-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.inbox-thread-actions {
    display: flex;
    gap: 4px;
}

.inbox-thread-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    opacity: 0.6;
    transition: opacity 0.15s;
    border-radius: 6px;
}

.inbox-thread-actions button:hover {
    opacity: 1;
    background: var(--bg-body);
}

.inbox-thread-subject-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    padding: 16px 16px 8px;
    margin: 0;
}

/* ===== MESSAGES ===== */
.inbox-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.inbox-message-card {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.inbox-message-card.outbound {
    background: #f8fafc;
}

.inbox-message-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-secondary);
}

.inbox-message-sender {
    font-weight: 600;
    color: var(--text-primary);
}

.inbox-message-date {
    color: var(--text-muted);
}

.inbox-message-body {
    padding: 16px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.inbox-message-body img {
    max-width: 100%;
    height: auto;
}

/* ===== REPLY BOX ===== */
.inbox-reply-box {
    margin: 0 16px 16px;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    overflow: hidden;
}

.inbox-reply-box textarea {
    width: 100%;
    min-height: 120px;
    border: none;
    padding: 12px 16px;
    resize: vertical;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-card);
    outline: none;
    box-sizing: border-box;
}

.inbox-reply-box textarea::placeholder {
    color: var(--text-muted);
}

.inbox-reply-actions {
    padding: 8px 16px;
    display: flex;
    justify-content: flex-end;
    background: #f8fafc;
    border-top: 1px solid var(--border-light);
}

/* ===== SEND BUTTON ===== */
.inbox-send-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: opacity 0.15s;
    font-family: inherit;
}

.inbox-send-btn:hover {
    opacity: 0.9;
}

/* ===== COMPOSE MODAL ===== */
.inbox-compose-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.inbox-compose-modal {
    background: var(--bg-card);
    border-radius: 16px;
    width: 600px;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.inbox-compose-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
}

.inbox-compose-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px 8px;
    border-radius: 6px;
    transition:
        background 0.15s,
        color 0.15s;
}

.inbox-compose-close:hover {
    background: var(--bg-body);
    color: var(--text-primary);
}

.inbox-compose-body {
    padding: 16px 20px;
    flex: 1;
    overflow-y: auto;
}

.inbox-compose-field {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.inbox-compose-field label {
    width: 60px;
    font-size: 12px;
    color: var(--text-secondary);
    text-align: right;
    flex-shrink: 0;
    font-weight: 500;
}

.inbox-compose-field input,
.inbox-compose-field select {
    flex: 1;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-card);
    outline: none;
    transition: border-color 0.15s;
}

.inbox-compose-field input:focus,
.inbox-compose-field select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.inbox-compose-body > textarea {
    width: 100%;
    min-height: 200px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-card);
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.inbox-compose-body > textarea:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.inbox-compose-body > textarea::placeholder {
    color: var(--text-muted);
}

.inbox-compose-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
}

/* ===== AUTOCOMPLETE ===== */
.inbox-autocomplete {
    position: absolute;
    top: 100%;
    left: 68px;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.inbox-autocomplete.show {
    display: block;
}

.inbox-autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}

.inbox-autocomplete-item:hover {
    background: var(--bg-body);
}

.inbox-autocomplete-item:first-child {
    border-radius: 8px 8px 0 0;
}

.inbox-autocomplete-item:last-child {
    border-radius: 0 0 8px 8px;
}

.inbox-autocomplete-name {
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inbox-autocomplete-email {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* ===== RESPONSIVE (max-width: 768px) ===== */
@media (max-width: 768px) {
    .inbox-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .inbox-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        padding: 12px;
        gap: 8px;
    }

    .inbox-compose-btn {
        padding: 8px 16px;
        font-size: 12px;
    }

    .inbox-folders {
        flex-direction: row;
        overflow-x: auto;
        gap: 4px;
        -webkit-overflow-scrolling: touch;
    }

    .inbox-folder-item {
        padding: 6px 12px;
        border-radius: 20px;
        background: var(--bg-body);
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 12px;
    }

    .inbox-folder-item.active {
        background: #eef2ff;
    }

    .inbox-thread-item {
        grid-template-columns: 24px 24px 1fr auto;
        gap: 6px;
        padding: 10px 12px;
    }

    /* Hide snippet on mobile, sender takes content column */
    .inbox-thread-sender {
        display: none;
    }

    .inbox-thread-content {
        grid-column: 3;
    }

    .inbox-thread-snippet {
        display: none;
    }

    .inbox-compose-modal {
        width: 95vw;
        max-height: 90vh;
        border-radius: 12px;
    }

    .inbox-compose-field {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }

    .inbox-compose-field label {
        width: auto;
        text-align: left;
    }

    .inbox-thread-subject-title {
        font-size: 16px;
        padding: 12px 12px 8px;
    }

    .inbox-messages {
        padding: 12px;
        gap: 12px;
    }

    .inbox-reply-box {
        margin: 0 12px 12px;
    }

    .inbox-autocomplete {
        left: 0;
    }

    .email-usage-inline {
        display: none;
    }

    .email-tabs-wrapper {
        flex-wrap: wrap;
    }

    .ai-filter-bar {
        padding: 6px 12px;
        gap: 4px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }

    .ai-filter-btn {
        padding: 4px 10px;
        font-size: 11px;
        flex-shrink: 0;
    }
}

/* ===== AI FILTER BAR ===== */
.ai-filter-bar {
    display: flex;
    gap: 6px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-light);
    background: #f8fafc;
    flex-wrap: wrap;
    align-items: center;
}

.ai-filter-btn {
    padding: 5px 12px;
    border: 1px solid var(--border-light);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
    white-space: nowrap;
}

.ai-filter-btn:hover {
    border-color: #667eea;
    color: #667eea;
    background: #eef2ff;
}

.ai-filter-btn.active {
    background: #eef2ff;
    border-color: #667eea;
    color: #667eea;
    font-weight: 600;
}

/* Colored active states per filter type */
.ai-filter-btn.ai-filter-drafts.active {
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    border-color: #8b5cf6;
    color: #7c3aed;
}

.ai-filter-btn.ai-filter-urgent.active {
    background: #fef2f2;
    border-color: #ef4444;
    color: #dc2626;
}

.ai-filter-btn.ai-filter-clients.active {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #2563eb;
}

.ai-filter-btn.ai-filter-spam.active {
    background: #fef2f2;
    border-color: #f87171;
    color: #ef4444;
}

.ai-filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    background: var(--border-light);
    color: var(--text-secondary);
    margin-left: 4px;
}

.ai-filter-btn.active .ai-filter-count {
    background: rgba(102, 126, 234, 0.15);
    color: inherit;
}

.ai-filter-btn.ai-filter-drafts .ai-filter-count {
    background: #ede9fe;
    color: #7c3aed;
}

.ai-filter-btn.ai-filter-urgent .ai-filter-count {
    background: #fee2e2;
    color: #dc2626;
}

/* ============================================
   EMAIL AI — Badges, Analysis Card, Draft Section
   ============================================ */

/* AI Category Labels — subtle text, not colorful chips */
.ai-cat-label {
    font-size: 11px;
    font-weight: 500;
    color: #94a3b8;
    white-space: nowrap;
}
.ai-cat-label.ai-cat-klient {
    color: #3b82f6;
}
.ai-cat-label.ai-cat-spam {
    color: #ef4444;
}
.ai-cat-label.ai-cat-b2b {
    color: #d97706;
}
.ai-cat-label.ai-cat-newsletter {
    color: #8b5cf6;
}
.ai-cat-label.ai-cat-system {
    color: #94a3b8;
}

/* Urgency dot — small colored circle */
.ai-urgency-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.ai-dot-critical {
    background: #ef4444;
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
    animation: ai-pulse 1.5s ease-in-out infinite;
}
.ai-dot-high {
    background: #f59e0b;
}

@keyframes ai-pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Draft/Sent icons — minimal */
.ai-draft-icon {
    font-size: 13px;
    color: #8b5cf6;
}
.ai-sent-icon {
    font-size: 13px;
    color: #22c55e;
    font-weight: 700;
}

/* AI Confidence */
.ai-confidence {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

/* ---- AI Analysis Card ---- */
.ai-analysis-card {
    background: linear-gradient(135deg, #f0f4ff 0%, #f5f3ff 100%);
    border: 1px solid #e0e7ff;
    border-radius: 12px;
    padding: 16px 20px;
    margin: 12px 0;
}
.ai-analysis-card.ai-pending {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.ai-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.ai-card-icon {
    font-size: 18px;
}
.ai-card-title {
    font-weight: 600;
    font-size: 14px;
    color: #1e293b;
}
.ai-card-status {
    font-size: 12px;
    color: #94a3b8;
}
.ai-card-badges {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: auto;
}
.ai-reclassify-btn {
    background: none;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 14px;
    color: #64748b;
    transition: all 0.2s;
}
.ai-reclassify-btn:hover {
    background: #f1f5f9;
    color: #334155;
}

.ai-card-summary {
    margin-top: 8px;
    font-size: 13px;
    color: #475569;
    line-height: 1.5;
}
.ai-card-error {
    margin-top: 8px;
    font-size: 12px;
    color: #ef4444;
    background: #fef2f2;
    padding: 6px 10px;
    border-radius: 6px;
}
.ai-card-hint {
    font-size: 13px;
    color: #94a3b8;
    margin: 8px 0;
}

/* AI Action Buttons (generic) */
.ai-action-btn {
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}
.ai-action-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}
.ai-classify-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
}
.ai-classify-btn:hover {
    filter: brightness(1.1);
}

/* ---- AI Draft Section ---- */
.ai-draft-section {
    border: 1px solid #e0e7ff;
    border-radius: 12px;
    padding: 16px 20px;
    margin: 16px 0;
}
.ai-draft-section.ai-draft-ready {
    background: linear-gradient(135deg, #faf5ff 0%, #f0f4ff 100%);
    border-color: #c4b5fd;
}
.ai-draft-section.ai-draft-sent {
    background: #f0fdf4;
    border-color: #86efac;
}
.ai-draft-section.ai-draft-rejected {
    background: #fef2f2;
    border-color: #fca5a5;
}
.ai-draft-section.ai-draft-pending {
    background: #fffbeb;
    border-color: #fde68a;
}
.ai-draft-section.ai-draft-none {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.ai-draft-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.ai-draft-title {
    font-weight: 600;
    font-size: 14px;
    color: #1e293b;
}
.ai-draft-header small {
    color: #94a3b8;
    font-size: 12px;
}

.ai-draft-textarea {
    width: 100%;
    min-height: 160px;
    margin-top: 12px;
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.6;
    color: #1e293b;
    resize: vertical;
    background: #fff;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.ai-draft-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-draft-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* Approve Button — primary NinjaBot brand gradient */
.ai-approve-btn {
    padding: 10px 24px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.ai-approve-btn:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}
.ai-approve-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: none;
    transform: none;
}

/* Reject Button */
.ai-reject-btn {
    padding: 10px 20px;
    background: #fff;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.ai-reject-btn:hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #ef4444;
}

/* Regenerate Button */
.ai-regenerate-btn {
    font-size: 12px;
    padding: 6px 12px;
}
.ai-generate-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
}
.ai-generate-btn:hover {
    filter: brightness(1.1);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .ai-analysis-card {
        padding: 12px 14px;
    }
    .ai-draft-actions {
        flex-direction: column;
    }
    .ai-approve-btn,
    .ai-reject-btn {
        width: 100%;
        text-align: center;
    }
    .ai-card-badges {
        margin-left: 0;
        margin-top: 8px;
    }
}
