/* ==========================================================================
   Pho Webmail Design System
   Modern Obsidian / Slate Aesthetic - High-End Mail Client
   ========================================================================== */

:root {
    /* Color Palette */
    --bg-base: #0a0d14;
    --bg-surface: #101522;
    --bg-surface-elevated: #161d30;
    --bg-surface-hover: #1c253d;
    --bg-surface-active: #222d4a;

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-focus: #38bdf8;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;

    /* Accents & Highlights */
    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    --accent-glow: rgba(59, 130, 246, 0.25);

    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --accent-purple: #8b5cf6;

    /* Typography */
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Layout metrics */
    --sidebar-width: 260px;
    --list-width: 380px;

    /* Transitions & Shadows */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --shadow-dropdown: 0 16px 36px -8px rgba(0, 0, 0, 0.6), 0 0 1px 1px rgba(255, 255, 255, 0.08);
    --shadow-modal: 0 25px 60px -15px rgba(0, 0, 0, 0.8), 0 0 1px 1px rgba(255, 255, 255, 0.12);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* Reset & Global */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: var(--font-sans);
    background-color: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ==========================================================================
   APP LAYOUT (3-PANES)
   ========================================================================== */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
    background: var(--bg-base);
}

/* ==========================================================================
   1. SIDEBAR
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    user-select: none;
    z-index: 10;
}

/* Brand */
.sidebar-header {
    padding: 20px 18px 16px 18px;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 14px var(--accent-glow);
}
.logo-icon svg {
    width: 20px;
    height: 20px;
}

.brand-info {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.2px;
}

.brand-domain {
    font-size: 11px;
    font-weight: 500;
    color: var(--accent-primary);
    font-family: var(--font-mono);
}

/* Compose Button */
.compose-wrapper {
    padding: 16px 16px 12px 16px;
}

.btn-compose {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 4px 16px var(--accent-glow);
    transition: all var(--transition-normal);
}
.btn-compose:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}
.btn-compose:active {
    transform: translateY(0);
}
.btn-compose svg {
    width: 18px;
    height: 18px;
}

/* Folders Nav */
.folder-nav {
    flex: 1;
    padding: 8px 12px;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    padding: 8px 10px 4px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all var(--transition-fast);
}

.nav-item:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
}

.nav-item.active {
    color: #fff;
    background: var(--bg-surface-active);
    font-weight: 600;
}

.nav-item svg {
    width: 17px;
    height: 17px;
    opacity: 0.8;
}

.nav-item.active svg {
    color: var(--accent-primary);
    opacity: 1;
}

.nav-label {
    flex: 1;
}

.badge {
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

.nav-item.active .badge {
    background: var(--accent-primary);
    color: #fff;
}

.badge.invoice-badge {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
    font-size: 10px;
    letter-spacing: 0.5px;
}

/* Sidebar Footer & Account */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-subtle);
}

.account-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.account-card:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-default);
}

.account-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.account-details {
    flex: 1;
    overflow: hidden;
}

.account-email {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-status {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
}
.status-dot.connected {
    background: var(--accent-emerald);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}
.status-dot.error {
    background: var(--accent-rose);
}

.status-text {
    font-size: 10.5px;
    color: var(--text-muted);
}

.btn-settings-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-settings-icon:hover {
    color: var(--text-primary);
}
.btn-settings-icon svg {
    width: 16px;
    height: 16px;
}

/* ==========================================================================
   2. CENTER: EMAIL LIST PANE
   ========================================================================== */
.email-list-pane {
    width: var(--list-width);
    min-width: var(--list-width);
    background: var(--bg-surface-elevated);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
}

/* List Toolbar */
.list-toolbar {
    padding: 14px 16px 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-box {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 8px 30px 8px 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--border-focus);
    background: var(--bg-base);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

.btn-clear-search {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
}

.btn-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-surface-hover);
    border-color: var(--border-default);
}
.btn-icon svg {
    width: 16px;
    height: 16px;
}
.btn-icon.spinning svg {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

/* Filter Pills */
.filter-pills {
    display: flex;
    gap: 6px;
    padding: 0 16px 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
}

.pill {
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-sans);
    font-size: 11.5px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.pill:hover {
    color: var(--text-primary);
    border-color: var(--border-default);
}

.pill.active {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--accent-primary);
    font-weight: 600;
}

/* Email items list */
.email-items-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: var(--text-muted);
    gap: 12px;
    font-size: 13px;
}
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Empty Mail List */
.empty-list-notice {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

/* Email Item Card */
.email-item-card {
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

.email-item-card:hover {
    background: var(--bg-surface);
    border-color: var(--border-subtle);
}

.email-item-card.active {
    background: var(--bg-surface-hover);
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.email-item-card.unread {
    background: rgba(59, 130, 246, 0.04);
}
.email-item-card.unread::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 16px;
    bottom: 16px;
    width: 3px;
    border-radius: 4px;
    background: var(--accent-primary);
}

.item-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.item-sender {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.email-item-card.unread .item-sender {
    color: #fff;
    font-weight: 700;
}

.item-date {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.item-subject {
    font-size: 12.5px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.email-item-card.unread .item-subject {
    color: var(--text-primary);
    font-weight: 600;
}

.item-snippet {
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.item-meta-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
}

.chip-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.chip-tag.invoice {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.chip-tag.attach {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

/* ==========================================================================
   3. RIGHT: EMAIL VIEWER PANE
   ========================================================================= */
.email-viewer-pane {
    flex: 1;
    background: var(--bg-base);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Empty State */
.viewer-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
}

.empty-icon-wrap {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    color: var(--text-secondary);
}
.empty-icon-wrap svg {
    width: 32px;
    height: 32px;
}

.viewer-empty-state h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.viewer-empty-state p {
    font-size: 13.5px;
    max-width: 400px;
    line-height: 1.5;
    margin-bottom: 20px;
}
.keyboard-shortcuts {
    font-size: 12px;
    padding: 6px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
}
.keyboard-shortcuts code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 5px;
    border-radius: 4px;
    color: var(--accent-primary);
    font-family: var(--font-mono);
}

/* Active Viewer Content */
.viewer-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.viewer-header {
    padding: 20px 24px 16px 24px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.viewer-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.email-subject-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    flex: 1;
}

.viewer-quick-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-action-round {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-action-round:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-default);
}
.btn-action-round svg {
    width: 14px;
    height: 14px;
}
.btn-action-round.danger:hover {
    background: rgba(244, 63, 94, 0.15);
    border-color: rgba(244, 63, 94, 0.3);
    color: var(--accent-rose);
}

/* Sender Box */
.viewer-sender-box {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sender-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0ea5e9, #3b82f6);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sender-meta {
    flex: 1;
}

.sender-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.sender-name {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.sender-email {
    font-size: 12px;
    color: var(--text-muted);
}

.sender-to-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}

.recipient-tag {
    color: var(--accent-primary);
}
.dot-separator {
    color: var(--text-muted);
}

.viewer-security-tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    color: var(--accent-emerald);
    font-size: 11px;
    font-weight: 600;
}
.viewer-security-tag svg {
    width: 13px;
    height: 13px;
}

/* Invoice Alert Banner */
.invoice-alert-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.invoice-icon {
    font-size: 24px;
}
.invoice-banner-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.invoice-banner-text strong {
    font-size: 13.5px;
    color: #34d399;
}
.invoice-banner-text span {
    font-size: 12px;
    color: #a7f3d0;
}

.btn-download-all-xml {
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    background: #059669;
    border: none;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-download-all-xml:hover {
    background: #10b981;
}

/* Attachments Section */
.viewer-attachments-section {
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attachments-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.attachments-label svg {
    width: 14px;
    height: 14px;
}

.attachments-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.attachment-chip:hover {
    background: var(--bg-surface-hover);
    border-color: var(--border-default);
}
.attachment-chip.xml {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.08);
}
.attachment-chip.pdf {
    border-color: rgba(244, 63, 94, 0.4);
    background: rgba(244, 63, 94, 0.08);
}

.chip-file-name {
    font-weight: 600;
}
.chip-file-size {
    color: var(--text-muted);
    font-size: 11px;
}

/* Viewer Body */
.viewer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    background: var(--bg-base);
}

.body-view-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.toggle-label {
    font-size: 11.5px;
    color: var(--text-muted);
}

.btn-toggle-view {
    background: transparent;
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    color: var(--text-muted);
    padding: 3px 8px;
    font-size: 11px;
    cursor: pointer;
}
.btn-toggle-view.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-default);
    font-weight: 600;
}

.mail-body-html-wrapper {
    flex: 1;
    min-height: 400px;
    background: #fff;
    border-radius: var(--radius-md);
    overflow: hidden;
}
.mail-body-html-wrapper iframe {
    width: 100%;
    height: 100%;
    min-height: 480px;
    border: none;
    display: block;
}

.mail-body-text-wrapper {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-word;
    padding: 16px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

/* ==========================================================================
   4. MODALS & POPUPS
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Compose Window */
.compose-window {
    width: 680px;
    max-width: 95vw;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.compose-header {
    padding: 14px 18px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.compose-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.btn-window-action {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}
.btn-window-action:hover {
    color: #fff;
    background: var(--bg-surface-hover);
}

.compose-form {
    display: flex;
    flex-direction: column;
}

.compose-fields {
    border-bottom: 1px solid var(--border-subtle);
}

.field-row {
    display: flex;
    align-items: center;
    padding: 8px 18px;
    border-bottom: 1px solid var(--border-subtle);
}
.field-row:last-child {
    border-bottom: none;
}

.field-row label {
    width: 60px;
    font-size: 13px;
    color: var(--text-muted);
}

.field-row input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13.5px;
    padding: 4px 0;
}
.field-row input:focus {
    outline: none;
}

.cc-toggle-buttons {
    display: flex;
    gap: 4px;
}

.btn-toggle-field {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    padding: 2px 6px;
    cursor: pointer;
}
.btn-toggle-field:hover {
    color: var(--accent-primary);
}

.compose-body-area {
    padding: 16px 18px;
}

.compose-body-area textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
}
.compose-body-area textarea:focus {
    outline: none;
}

/* Compose Attached Files */
.compose-attached-files {
    padding: 8px 18px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid var(--border-subtle);
}
.attached-header {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.attached-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.attached-chip-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    font-size: 11.5px;
    color: var(--text-primary);
}
.btn-remove-att {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 12px;
}
.btn-remove-att:hover {
    color: var(--accent-rose);
}

.compose-footer {
    padding: 12px 18px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-attach {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 12.5px;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-attach:hover {
    color: #fff;
    background: var(--bg-surface-hover);
}
.btn-attach svg {
    width: 14px;
    height: 14px;
}

.file-hint {
    font-size: 11.5px;
    color: var(--text-muted);
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 13px;
    cursor: pointer;
}
.btn-secondary:hover {
    color: #fff;
    background: var(--bg-surface-hover);
}

.btn-primary-send {
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    background: var(--accent-gradient);
    border: none;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 14px var(--accent-glow);
    transition: all var(--transition-fast);
}
.btn-primary-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.4);
}
.btn-primary-send svg {
    width: 15px;
    height: 15px;
}

/* Settings Dialog */
.settings-dialog {
    width: 520px;
    max-width: 95vw;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.settings-header {
    padding: 16px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.settings-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.settings-content {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    max-height: 75vh;
}

.settings-note {
    font-size: 12.5px;
    color: var(--text-secondary);
    background: rgba(59, 130, 246, 0.08);
    border-left: 3px solid var(--accent-primary);
    padding: 10px 12px;
    border-radius: 4px;
    line-height: 1.5;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.settings-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.settings-group input {
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 13px;
}
.settings-group input:focus {
    outline: none;
    border-color: var(--border-focus);
}
.field-hint {
    font-size: 11px;
    color: var(--text-muted);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Diag results */
.test-connection-box {
    margin-top: 6px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.test-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}
.btn-test-action {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--accent-primary);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.btn-test-action:hover {
    background: rgba(59, 130, 246, 0.25);
}
.diag-results {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--text-muted);
    background: #000;
    padding: 8px 10px;
    border-radius: 4px;
    white-space: pre-wrap;
    line-height: 1.4;
}

.settings-footer {
    padding: 14px 20px;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    padding: 12px 18px;
    border-radius: var(--radius-md);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-dropdown);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideUp 0.3s ease;
    pointer-events: auto;
}
.toast.success {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}
.toast.error {
    border-color: rgba(244, 63, 94, 0.4);
    background: rgba(244, 63, 94, 0.15);
    color: #fb7185;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ==========================================================================
   5. LOGIN VIEW
   ========================================================================== */
.login-view-wrapper {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 20%, rgba(59, 130, 246, 0.12), transparent 60%),
                radial-gradient(circle at 80% 80%, rgba(99, 102, 241, 0.08), transparent 50%),
                var(--bg-base);
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.login-card {
    width: 440px;
    max-width: 100%;
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 1px 1px rgba(255, 255, 255, 0.1);
    padding: 36px 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    backdrop-filter: blur(16px);
}

.login-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.login-logo-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 8px 24px var(--accent-glow);
    margin-bottom: 6px;
}
.login-logo-icon svg {
    width: 28px;
    height: 28px;
}

.login-header h2 {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.3px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}
.login-subtitle strong {
    color: var(--accent-primary);
    font-family: var(--font-mono);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-error-alert {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fb7185;
    font-size: 12.5px;
    line-height: 1.4;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.login-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.login-field-group label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
}

.field-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.host-info-hint {
    font-size: 11px;
    color: var(--accent-emerald);
    font-family: var(--font-mono);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon .field-icon {
    position: absolute;
    left: 14px;
    width: 17px;
    height: 17px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition-fast);
}

.input-with-icon input {
    width: 100%;
    padding: 11px 40px 11px 42px;
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    color: #fff;
    font-family: var(--font-sans);
    font-size: 14px;
    transition: all var(--transition-fast);
}

.input-with-icon input:focus {
    outline: none;
    border-color: var(--border-focus);
    background: var(--bg-base);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}
.input-with-icon input:focus ~ .field-icon {
    color: var(--border-focus);
}

.btn-eye {
    position: absolute;
    right: 12px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.btn-eye:hover {
    color: var(--text-primary);
}
.btn-eye svg {
    width: 17px;
    height: 17px;
}

.login-options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12.5px;
}

.remember-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    user-select: none;
}
.remember-checkbox input {
    accent-color: var(--accent-primary);
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.btn-login-primary {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--accent-gradient);
    border: none;
    color: #fff;
    font-family: var(--font-sans);
    font-size: 14.5px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 16px var(--accent-glow);
    transition: all var(--transition-fast);
    margin-top: 6px;
}
.btn-login-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.4);
}
.btn-login-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.login-footer {
    text-align: center;
    font-size: 11.5px;
    color: var(--text-muted);
}
.login-footer code {
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.btn-logout:hover {
    color: var(--accent-rose) !important;
    background: rgba(244, 63, 94, 0.15) !important;
}

