/* ============================================================
   MailBox — Explyra Email Client
   Vercel-inspired SaaS Design System
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --text-primary: #000000;
    --text-secondary: #666666;
    --border-color: #eaeaea;
    --accent-color: #000000;
    --card-bg: #ffffff;
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    --sidebar-bg: #ffffff;
    --header-bg: rgba(255, 255, 255, 0.8);
    --radius-md: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --font-size: 14px;

    --success: #22c55e;
    --success-bg: #f0fdf4;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --purple: #8b5cf6;
    --purple-bg: #f5f3ff;

    --bg-image: none;
    --bg-opacity: 1;
}

.dark, [data-theme='dark'] {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --border-color: #1a1a1a;
    --accent-color: #ffffff;
    --card-bg: #0a0a0a;
    --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    --sidebar-bg: #000000;
    --header-bg: rgba(0, 0, 0, 0.8);

    --success-bg: rgba(34, 197, 94, 0.1);
    --danger-bg: rgba(239, 68, 68, 0.1);
    --info-bg: rgba(59, 130, 246, 0.1);
    --warning-bg: rgba(245, 158, 11, 0.1);
    --purple-bg: rgba(139, 92, 246, 0.1);
}

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

body {
    font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-primary);
    background-image: var(--bg-image);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    color: var(--text-primary);
    font-size: var(--font-size);
    line-height: 1.5;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow: hidden;
    height: 100vh;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }

/* Background Overlay */
.bg-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, calc(1 - var(--bg-opacity)));
    z-index: -1;
    pointer-events: none;
}
.dark .bg-overlay, [data-theme='dark'] .bg-overlay {
    background: rgba(0, 0, 0, calc(1 - var(--bg-opacity)));
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ---------- Utilities ---------- */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-1 { flex: 1; min-width: 0; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.min-w-0 { min-width: 0; }
.text-center { text-align: center; }
.relative { position: relative; }
.w-full { width: 100%; }
.space-y-4 > * + * { margin-top: 1rem; }
.space-y-2 > * + * { margin-top: 0.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-12 { margin-top: 3rem; }
.ml-2 { margin-left: 0.5rem; }
.p-4 { padding: 1rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-2xl { font-size: 1.5rem; }
.text-3xl { font-size: 1.875rem; }

/* ---------- Login Screen ---------- */
#login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    position: relative;
    z-index: 10;
    background: var(--bg-primary);
}

.login-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

.login-icon-box {
    width: 48px;
    height: 48px;
    background: var(--accent-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

.login-icon-box svg { width: 24px; height: 24px; color: var(--bg-primary); stroke: var(--bg-primary); }

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
}

.login-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.input-vercel {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    outline: none;
    transition: var(--transition);
}

.input-vercel:focus {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 1px var(--text-primary);
}

.input-vercel::placeholder { color: var(--text-secondary); }

.input-group {
    position: relative;
}

.input-suffix {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    pointer-events: none;
}

.btn-primary {
    width: 100%;
    background: var(--accent-color);
    color: var(--bg-primary);
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.625rem 1rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover { opacity: 0.85; transform: scale(0.98); }

.btn-secondary {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    transition: var(--transition);
}

.btn-secondary:hover { background: var(--bg-secondary); border-color: var(--text-secondary); }

.login-toggle-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.login-toggle-text button {
    color: var(--text-primary);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.login-footer {
    margin-top: 2rem;
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

/* ---------- App Shell ---------- */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: var(--transition);
    z-index: 50;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.25rem 0.75rem;
}

.sidebar-brand-logo {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    background: var(--accent-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand-icon svg { width: 16px; height: 16px; stroke: var(--bg-primary); }

.sidebar-brand-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.sidebar-close {
    display: none;
    padding: 0.25rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Compose Button */
.compose-btn-wrapper { padding: 0.75rem 1rem; }

.compose-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    background: var(--accent-color);
    color: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.compose-btn:hover { opacity: 0.85; transform: scale(0.98); }
.compose-btn svg { width: 16px; height: 16px; }

/* Sidebar Navigation */
.sidebar-nav { flex: 1; padding: 0 0.5rem; overflow-y: auto; }

.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    padding: 1rem 0.75rem 0.375rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    width: 100%;
    text-align: left;
}

.sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.5; }

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

.sidebar-item.active {
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-weight: 600;
}

.sidebar-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent-color);
    border-radius: 0 3px 3px 0;
}

.sidebar-item-count {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.1rem 0.45rem;
    border-radius: 9999px;
    min-width: 20px;
    text-align: center;
}

.sidebar-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0.75rem;
}

/* Sidebar User Footer */
.sidebar-user {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    object-fit: cover;
    flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-email {
    font-size: 0.65rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-logout {
    padding: 0.375rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar-user-logout:hover { color: var(--danger); background: var(--danger-bg); }
.sidebar-user-logout svg { width: 18px; height: 18px; }

/* ---------- Main Wrapper ---------- */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

/* ---------- Header Bar ---------- */
.header-bar {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    z-index: 20;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-hamburger {
    display: none;
    padding: 0.375rem;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.header-hamburger svg { width: 20px; height: 20px; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Search Bar */
.search-wrapper {
    position: relative;
    flex: 1;
    max-width: 480px;
}

.search-wrapper svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    pointer-events: none;
}

.search-bar {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    padding: 0.5rem 1rem 0.5rem 2.25rem;
    font-size: 0.8rem;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.search-bar:focus {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 1px var(--text-primary);
    background: var(--bg-primary);
}

.search-bar::placeholder { color: var(--text-secondary); }

/* Advanced Search Panel */
.advanced-search-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0; right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    z-index: 120;
}

.advanced-search-panel .grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.advanced-search-panel input[type="text"] {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.advanced-search-panel input[type="text"]:focus {
    border-color: var(--text-primary);
}

.filter-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.25rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.filter-btn:hover { color: var(--text-primary); }
.filter-btn svg { width: 16px; height: 16px; }

/* Header Icon Button */
.header-icon-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: var(--transition);
}

.header-icon-btn:hover { background: var(--bg-secondary); color: var(--text-primary); }
.header-icon-btn svg { width: 18px; height: 18px; }

/* Theme Pill */
.theme-pill {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    padding: 2px;
    gap: 2px;
}

.theme-pill button {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.theme-pill button.active-theme {
    background: var(--card-bg);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.theme-pill button svg { width: 14px; height: 14px; }

/* Profile Avatar */
.profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    overflow: hidden;
    flex-shrink: 0;
}

.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Content Panels ---------- */
.content-area {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ---------- Email List Panel ---------- */
.email-list-panel {
    width: 400px;
    min-width: 320px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.email-list-header {
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.email-list-header-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.email-list-scroll {
    flex: 1;
    overflow-y: auto;
}

/* Email Row */
.email-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.email-row:hover {
    background: var(--bg-secondary);
}

.email-row.unread { font-weight: 600; }

.email-row.read {
    opacity: 0.7;
}

.email-row .email-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-color);
    flex-shrink: 0;
    cursor: pointer;
}

.email-row .email-star {
    flex-shrink: 0;
    color: var(--border-color);
    transition: var(--transition);
    padding: 2px;
}

.email-row .email-star:hover { color: var(--warning); }
.email-row .email-star.starred { color: var(--warning); fill: var(--warning); }
.email-row .email-star svg { width: 16px; height: 16px; }

.email-sender {
    width: 140px;
    flex-shrink: 0;
    font-size: 0.8rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-row.unread .email-sender { font-weight: 700; }

.email-content {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 0.375rem;
    font-size: 0.8rem;
}

.email-subject {
    font-weight: 600;
    flex-shrink: 0;
    max-width: 40%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-row.read .email-subject { font-weight: 500; }

.email-preview {
    color: var(--text-secondary);
    font-weight: 400;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.email-preview::before {
    content: '— ';
    color: var(--text-secondary);
}

.email-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    min-width: 50px;
    text-align: right;
}

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

.empty-state img { width: 80px; opacity: 0.15; margin-bottom: 1rem; }
.empty-state p { font-size: 0.875rem; font-weight: 500; }

/* ---------- Detail Panel ---------- */
.detail-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-width: 0;
}

.detail-header {
    height: 56px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.detail-header-btn {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: var(--transition);
}

.detail-header-btn:hover { background: var(--bg-secondary); color: var(--text-primary); }
.detail-header-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }
.detail-header-btn svg { width: 18px; height: 18px; }

.detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 2.5rem;
}

.detail-subject {
    font-size: 1.5rem;
    font-weight: 300;
    letter-spacing: -0.02em;
    margin-bottom: 2rem;
    line-height: 1.3;
}

.detail-header-info {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2rem;
}

.detail-header-info:hover { background: var(--bg-secondary); }

.detail-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-color);
    color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.detail-from-name {
    font-weight: 700;
    font-size: 0.9rem;
}

.detail-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

.detail-metadata {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    line-height: 1.8;
}

.detail-metadata strong { color: var(--text-primary); opacity: 0.7; }

.detail-toggle-meta {
    font-size: 0.65rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
    transition: var(--transition);
}

.detail-toggle-meta:hover { color: var(--info); }
.detail-toggle-meta svg { width: 12px; height: 12px; }

/* Email Body */
.email-body-container {
    line-height: 1.7;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.email-body-container iframe {
    width: 100%;
    min-height: 400px;
    border: none;
}

.email-body-container .text-fallback {
    white-space: pre-wrap;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* Reply / Forward */
.detail-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.detail-action-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: var(--transition);
}

.detail-action-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--text-secondary);
}

.detail-action-btn svg { width: 14px; height: 14px; }

/* ---------- Contacts Panel ---------- */
.contacts-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.contacts-header {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.contacts-header h2 { font-size: 1rem; font-weight: 700; }

.contacts-grid {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    align-content: start;
}

.contact-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.contact-card:hover { border-color: var(--text-secondary); }

.contact-avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--info-bg);
    color: var(--info);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

/* ---------- Calendar Panel ---------- */
.calendar-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.calendar-header {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.calendar-header h2 { font-size: 1rem; font-weight: 700; }

.calendar-nav-btn {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: var(--transition);
}

.calendar-nav-btn:hover { background: var(--bg-secondary); }
.calendar-nav-btn svg { width: 14px; height: 14px; }

.calendar-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-top: 1px solid var(--border-color);
    border-left: 1px solid var(--border-color);
}

.calendar-grid > div {
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem;
    min-height: 90px;
    transition: var(--transition);
}

.calendar-grid > div:hover { background: var(--bg-secondary); }

.calendar-day-marker {
    font-size: 0.7rem;
    background: var(--info-bg);
    color: var(--info);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    display: block;
    margin-top: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- Compose Modal ---------- */
#compose-modal {
    z-index: 100;
}

.compose-modal {
    width: 560px;
    max-width: 90vw;
    height: 560px;
    bottom: 0;
    right: 80px;
    position: fixed;
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.1);
    z-index: 100;
    overflow: hidden;
}

.compose-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--accent-color);
    color: var(--bg-primary);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.compose-header-close {
    color: var(--bg-primary);
    opacity: 0.7;
    padding: 0.25rem;
    transition: var(--transition);
}

.compose-header-close:hover { opacity: 1; }
.compose-header-close svg { width: 18px; height: 18px; }

.compose-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
}

.compose-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem;
}

.compose-field input {
    flex: 1;
    padding: 0.625rem 0;
    border: none;
    outline: none;
    font-size: 0.85rem;
    background: transparent;
    color: var(--text-primary);
}

.compose-field input::placeholder { color: var(--text-secondary); }

.compose-contacts-btn {
    padding: 0.25rem;
    color: var(--text-secondary);
    transition: var(--transition);
}

.compose-contacts-btn:hover { color: var(--info); }
.compose-contacts-btn svg { width: 18px; height: 18px; }

.contact-dropdown {
    position: absolute;
    top: 50px;
    right: 1rem;
    width: 240px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
    max-height: 180px;
    overflow-y: auto;
    z-index: 120;
}

.contact-dropdown > div {
    padding: 0.625rem 0.875rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
}

.contact-dropdown > div:last-child { border-bottom: none; }
.contact-dropdown > div:hover { background: var(--bg-secondary); }

.compose-editor {
    flex: 1;
    padding: 0.5rem 1rem;
}

.compose-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.compose-send-btn {
    padding: 0.5rem 1.5rem;
    background: var(--accent-color);
    color: var(--bg-primary);
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.compose-send-btn:hover { opacity: 0.85; }

.compose-discard-btn {
    color: var(--text-secondary);
    padding: 0.375rem;
    transition: var(--transition);
}

.compose-discard-btn:hover { color: var(--danger); }
.compose-discard-btn svg { width: 20px; height: 20px; }

/* ---------- Settings Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.12);
}

.modal-panel-sm { max-width: 440px; }

.modal-header {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.modal-header h3 { font-size: 1rem; font-weight: 700; }

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--text-secondary);
    transition: var(--transition);
}

.modal-close:hover { background: var(--bg-secondary); color: var(--text-primary); }
.modal-close svg { width: 18px; height: 18px; }

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* Settings Sections */
.settings-section { margin-bottom: 2rem; }

.settings-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

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

.settings-label {
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 0.375rem;
    display: block;
}

.settings-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.75rem;
    font-size: 0.8rem;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition);
}

.settings-input:focus { border-color: var(--text-primary); }

.color-swatch {
    width: 100%;
    height: 44px;
    border-radius: var(--radius-sm);
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
}

.color-swatch:hover, .color-swatch.active { border-color: var(--accent-color); }

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-top: 1px solid var(--border-color);
}

.settings-toggle-label p:first-child { font-size: 0.875rem; font-weight: 500; }
.settings-toggle-label p:last-child { font-size: 0.7rem; color: var(--text-secondary); }

/* Toggle Switch */
.toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--border-color);
    border-radius: 9999px;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-switch.active { background: var(--accent-color); }

.toggle-switch .toggle-dot {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-switch.active .toggle-dot { transform: translateX(20px); }

/* Toggle (checkbox based) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.peer:checked + .toggle-track { background: var(--accent-color); }
.peer:checked + .toggle-track::after { transform: translateX(20px); }

.toggle-track {
    width: 44px;
    height: 24px;
    background: var(--border-color);
    border-radius: 9999px;
    position: relative;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 200;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }

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

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

.slide-up { animation: slideUp 0.3s ease-out; }
.animate-fade-in { animation: fadeIn 0.4s ease-out forwards; }

/* ---------- Quill Overrides ---------- */
.ql-toolbar.ql-snow {
    border: none !important;
    border-bottom: 1px solid var(--border-color) !important;
    padding: 0.5rem 0.75rem !important;
}

.ql-container.ql-snow {
    border: none !important;
    font-size: 0.875rem;
}

.ql-editor { padding: 0.75rem !important; color: var(--text-primary); }
.ql-editor.ql-blank::before { color: var(--text-secondary) !important; }

/* ---------- Bulk Actions ---------- */
.bulk-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.5rem;
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        inset-block: 0;
        left: 0;
        transform: translateX(-100%);
    }

    .sidebar.sidebar-open { transform: translateX(0); }

    .sidebar-close { display: flex; }
    .header-hamburger { display: flex; }

    .email-list-panel { width: 100%; border-right: none; }

    .detail-panel {
        position: fixed;
        inset: 0;
        z-index: 40;
    }
}

@media (max-width: 768px) {
    .compose-modal {
        right: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .email-content { display: none; }
    .email-sender { width: auto; flex: 1; }

    .search-wrapper { display: none; }

    .detail-body { padding: 1.5rem; }
    .detail-subject { font-size: 1.25rem; }

    .advanced-search-panel .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Sidebar Overlay ---------- */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: all;
}

/* ---------- Settings Option Cards ---------- */
.settings-option-card {
    padding: 1rem;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.settings-option-card.active {
    border-color: var(--accent-color);
    background: var(--bg-secondary);
}

/* ---------- Prose Overrides ---------- */
.prose { max-width: none; }
.prose a { color: var(--info); }
.prose img { border-radius: var(--radius-sm); }

/* ============================================================
   Tailwind Utility Compat (used by app.js dynamic HTML)
   ============================================================ */

/* Sizing */
.w-5 { width: 1.25rem; }
.h-5 { height: 1.25rem; }
.w-6 { width: 1.5rem; }
.h-6 { height: 1.5rem; }
.w-12 { width: 3rem; }
.h-12 { height: 3rem; }
.w-24 { width: 6rem; }
.w-48 { width: 12rem; }
.min-h-\[100px\] { min-height: 100px; }

/* Flex utilities (already have most, add missing) */
.flex-shrink-0 { flex-shrink: 0; }
.cursor-pointer { cursor: pointer; }

/* Spacing */
.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.mt-1 { margin-top: 0.25rem; }
.ml-2 { margin-left: 0.5rem; }

/* Border */
.rounded { border-radius: 0.25rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-full { border-radius: 9999px; }
.border-r { border-right: 1px solid var(--border-color); }
.border-b { border-bottom: 1px solid var(--border-color); }
.border-gray-300 { border-color: #d1d5db; }

/* Colors - Text */
.text-white { color: #ffffff; }
.text-gray-200 { color: #e5e7eb; }
.text-gray-300 { color: #d1d5db; }
.text-gray-400 { color: #9ca3af; }
.text-gray-500 { color: #6b7280; }
.text-yellow-400 { color: #facc15; }
.text-blue-600 { color: #2563eb; }
.text-blue-700 { color: #1d4ed8; }
.text-blue-200 { color: #bfdbfe; }
.text-red-500 { color: #ef4444; }
.font-normal { font-weight: 400; }
.opacity-80 { opacity: 0.8; }
.fill-current { fill: currentColor; }
.transition-colors { transition: color 0.15s ease, background-color 0.15s ease; }

/* Colors - Background */
.bg-gray-50 { background-color: #f9fafb; }
.bg-gray-50\/30 { background-color: rgba(249, 250, 251, 0.3); }
.bg-gray-800 { background-color: #1f2937; }
.bg-blue-100 { background-color: #dbeafe; }
.bg-blue-900 { background-color: #1e3a5f; }
.bg-emerald-500 { background-color: #10b981; }
.bg-red-500 { background-color: #ef4444; }

/* Hover */
.hover\:bg-gray-50:hover { background-color: #f9fafb; }
.hover\:text-red-500:hover { color: #ef4444; }

/* Shadow */
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1); }

/* Fixed & Position */
.fixed { position: fixed; }
.bottom-4 { bottom: 1rem; }
.left-4 { left: 1rem; }
.z-\[200\] { z-index: 200; }
.text-\[10px\] { font-size: 10px; }

/* Dark mode compat */
.dark .dark\:text-white { color: #ffffff; }
.dark .dark\:text-gray-200 { color: #e5e7eb; }
.dark .dark\:text-gray-400 { color: #9ca3af; }
.dark .dark\:bg-gray-700 { background-color: #374151; }
.dark .dark\:bg-gray-800 { background-color: #1f2937; }
.dark .dark\:bg-gray-800\/50 { background-color: rgba(31, 41, 55, 0.5); }
.dark .dark\:hover\:bg-gray-800:hover { background-color: #1f2937; }
.dark .dark\:border-gray-800 { border-color: #1f2937; }
.dark .dark\:bg-gray-900\/10 { background-color: rgba(17, 24, 39, 0.1); }
.dark .dark\:bg-blue-900 { background-color: #1e3a5f; }
.dark .dark\:text-blue-200 { color: #bfdbfe; }

[data-theme='dark'] .dark\:text-white { color: #ffffff; }
[data-theme='dark'] .dark\:text-gray-200 { color: #e5e7eb; }
[data-theme='dark'] .dark\:text-gray-400 { color: #9ca3af; }
[data-theme='dark'] .dark\:bg-gray-700 { background-color: #374151; }
[data-theme='dark'] .dark\:bg-gray-800 { background-color: #1f2937; }
[data-theme='dark'] .dark\:bg-gray-800\/50 { background-color: rgba(31, 41, 55, 0.5); }
[data-theme='dark'] .dark\:hover\:bg-gray-800:hover { background-color: #1f2937; }
[data-theme='dark'] .dark\:border-gray-800 { border-color: #1f2937; }
[data-theme='dark'] .dark\:bg-gray-900\/10 { background-color: rgba(17, 24, 39, 0.1); }
[data-theme='dark'] .dark\:bg-blue-900 { background-color: #1e3a5f; }
[data-theme='dark'] .dark\:text-blue-200 { color: #bfdbfe; }

/* Override email row to be compact */
.email-row {
    padding: 0.5rem 0.875rem;
    gap: 0.5rem;
    font-size: 0.8rem;
}

/* Star icon size override — keep small */
.email-row svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Sender column smaller */
.email-row .w-48 {
    width: 10rem;
    gap: 0.5rem;
}

/* Checkbox sizing */
.email-row input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--accent-color);
}
