/* =============================================
   MailHub Pro - Professional Email Suite
   Clean Design System v3.0
   ============================================= */

:root {
    /* Light Theme (Default) */
    --bg-primary: #f8f9fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f5;
    --bg-hover: rgba(0,0,0,0.03);
    --bg-active: rgba(37, 99, 235, 0.06);
    --bg-card: #ffffff;
    --bg-input: #f8f9fb;
    --bg-sidebar: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.92);
    --bg-elevated: #ffffff;
    --bg-selection: rgba(37, 99, 235, 0.08);
    --border: rgba(0,0,0,0.07);
    --border-light: rgba(0,0,0,0.12);
    --border-focus: rgba(37, 99, 235, 0.4);
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --text-inverse: #f9fafb;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: #3b82f6;
    --accent-light: rgba(37, 99, 235, 0.08);
    --accent-glow: rgba(37, 99, 235, 0.12);
    --success: #059669;
    --success-light: rgba(5, 150, 105, 0.08);
    --warning: #d97706;
    --warning-light: rgba(217, 119, 6, 0.08);
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-light: rgba(220, 38, 38, 0.06);
    --info: #2563eb;
    --info-light: rgba(37, 99, 235, 0.06);
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 10px 10px -5px rgba(0,0,0,0.03);
    --shadow-glow: none;
    --shadow-inner: inset 0 1px 2px rgba(0,0,0,0.04);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --radius-full: 9999px;
    --transition: all 0.15s ease;
    --transition-fast: all 0.1s ease;
    --transition-slow: all 0.25s ease;
    --transition-bounce: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
    --sidebar-width: 260px;
    --toolbar-height: 52px;
    --blur: blur(12px);
    --blur-heavy: blur(20px);
}

[data-theme="dark"] {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-tertiary: #242836;
    --bg-hover: rgba(255,255,255,0.04);
    --bg-active: rgba(37, 99, 235, 0.1);
    --bg-card: #1a1d27;
    --bg-input: #141620;
    --bg-sidebar: #141620;
    --bg-glass: rgba(20, 22, 32, 0.92);
    --bg-elevated: #1e2230;
    --bg-selection: rgba(37, 99, 235, 0.12);
    --border: rgba(255,255,255,0.06);
    --border-light: rgba(255,255,255,0.1);
    --border-focus: rgba(37, 99, 235, 0.5);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #4b5563;
    --text-inverse: #0f172a;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.5);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.5);
    --shadow-glow: none;
    --shadow-inner: inset 0 1px 3px rgba(0,0,0,0.2);
}

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

html {
    font-size: 14.5px;
    scroll-behavior: smooth;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

::selection {
    background: var(--bg-selection);
    color: var(--text-primary);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: var(--transition);
}
a:hover { color: var(--accent-hover); }

img { max-width: 100%; display: block; }

/* =============================================
   Scrollbar
   ============================================= */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}

/* =============================================
   Skeleton Loading Animations
   ============================================= */
.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--bg-tertiary);
    border-radius: var(--radius-xs);
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

.skeleton-text { height: 14px; margin-bottom: 8px; border-radius: 4px; }
.skeleton-text.w-75 { width: 75%; }
.skeleton-text.w-50 { width: 50%; }
.skeleton-text.w-25 { width: 25%; }
.skeleton-circle { border-radius: 50%; }
.skeleton-avatar { width: 40px; height: 40px; border-radius: var(--radius-sm); }

/* =============================================
   Auth Pages (Login/Register)
   ============================================= */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.auth-bg {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
}

.auth-bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: orbFloat 20s ease-in-out infinite;
}

.auth-bg-orb:nth-child(1) {
    width: 400px; height: 400px;
    background: rgba(37,99,235,0.1);
    top: -10%; left: -5%;
}

.auth-bg-orb:nth-child(2) {
    width: 300px; height: 300px;
    background: rgba(37,99,235,0.07);
    bottom: -15%; right: -5%;
    animation-delay: -7s;
}

.auth-bg-orb:nth-child(3) {
    width: 200px; height: 200px;
    background: rgba(59,130,246,0.05);
    top: 50%; left: 60%;
    animation-delay: -14s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

.auth-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%232563eb' fill-opacity='0.02'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    z-index: 0;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-xl);
    animation: cardIn 0.4s ease;
}

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

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo-icon {
    width: 56px;
    height: 56px;
    background: var(--accent);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.auth-logo-icon svg {
    width: 28px;
    height: 28px;
    color: white;
}

.auth-logo h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.auth-logo p {
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-size: 0.9rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* =============================================
   Alerts / Messages
   ============================================= */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    margin-bottom: 1.5rem;
    animation: alertIn 0.2s ease;
}

@keyframes alertIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; }

.alert-error {
    background: var(--danger-light);
    border: 1px solid rgba(220,38,38,0.15);
    color: var(--danger);
}
.alert-error svg { color: var(--danger); }

.alert-success {
    background: var(--success-light);
    border: 1px solid rgba(5,150,105,0.15);
    color: var(--success);
}
.alert-success svg { color: var(--success); }

.alert-warning {
    background: var(--warning-light);
    border: 1px solid rgba(217,119,6,0.15);
    color: var(--warning);
}
.alert-warning svg { color: var(--warning); }

.alert-info {
    background: var(--info-light);
    border: 1px solid rgba(37,99,235,0.15);
    color: var(--info);
}
.alert-info svg { color: var(--info); }

[data-theme="dark"] .alert-error { color: #fca5a5; }
[data-theme="dark"] .alert-success { color: #6ee7b7; }
[data-theme="dark"] .alert-warning { color: #fcd34d; }
[data-theme="dark"] .alert-info { color: #93c5fd; }

/* =============================================
   Forms
   ============================================= */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-label .required { color: var(--danger); }

.form-input-wrapper {
    position: relative;
}

.form-input-wrapper .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: var(--transition);
}

.form-input-wrapper .input-icon svg {
    width: 18px;
    height: 18px;
}

.form-input-wrapper:focus-within .input-icon {
    color: var(--accent);
}

.form-input {
    width: 100%;
    padding: 0.65rem 1rem 0.65rem 2.75rem;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.93rem;
    font-family: var(--font);
    transition: var(--transition);
    outline: none;
}

.form-input:hover {
    border-color: var(--border-light);
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: var(--bg-secondary);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input.no-icon {
    padding-left: 1rem;
}

.form-input.input-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.form-input.input-lg {
    padding: 0.85rem 1.1rem;
    font-size: 1rem;
}

select.form-input {
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 2.5rem;
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.form-hint svg { width: 13px; height: 13px; }

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-checkbox input[type="checkbox"] {
    appearance: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--border-light);
    border-radius: 5px;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    flex-shrink: 0;
}

.form-checkbox input[type="checkbox"]:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.form-checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.form-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    cursor: pointer;
}

.form-toggle-track {
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    position: relative;
    transition: var(--transition);
    flex-shrink: 0;
}

.form-toggle-track::after {
    content: '';
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: var(--transition);
    box-shadow: var(--shadow-xs);
}

.form-toggle input:checked + .form-toggle-track {
    background: var(--accent);
}

.form-toggle input:checked + .form-toggle-track::after {
    transform: translateX(20px);
}

.form-toggle input { display: none; }

/* =============================================
   Buttons
   ============================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.15rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    white-space: nowrap;
    text-decoration: none;
    position: relative;
    user-select: none;
}

.btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem;
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border: 1.5px solid var(--accent);
}

.btn-outline:hover {
    background: var(--accent-light);
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

.btn-icon-lg {
    width: 42px;
    height: 42px;
}

.btn-sm {
    padding: 0.4rem 0.85rem;
    font-size: 0.82rem;
    border-radius: var(--radius-xs);
}

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

.btn-lg {
    padding: 0.85rem 1.75rem;
    font-size: 1rem;
    border-radius: var(--radius);
}

.btn-block { width: 100%; }

.btn:disabled, .btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-loading {
    pointer-events: none;
    position: relative;
    color: transparent !important;
}

.btn-loading::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-group {
    display: inline-flex;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

.btn-group .btn {
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--border);
}

.btn-group .btn:last-child { border-right: none; }

/* =============================================
   App Layout
   ============================================= */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-primary);
}

/* =============================================
   Sidebar
   ============================================= */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    transition: var(--transition-slow);
    z-index: 100;
    position: relative;
}

.sidebar-header {
    padding: 1rem 1.1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: var(--toolbar-height);
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo svg {
    width: 18px;
    height: 18px;
    color: white;
}

.sidebar-brand {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.sidebar-collapse-btn {
    margin-left: auto;
}

/* Compose Button in Sidebar */
.sidebar-compose {
    padding: 0.85rem 0.75rem;
}

.sidebar-compose .btn {
    width: 100%;
    padding: 0.65rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
}

/* Account Switcher */
.account-section {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.account-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 0.5rem;
    margin-bottom: 0.25rem;
}

.section-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.account-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    margin-bottom: 2px;
}

.account-item:hover { background: var(--bg-hover); }

.account-item.active {
    background: var(--bg-active);
}

.account-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    bottom: 25%;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.account-dot {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.account-label {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.account-email-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-badge {
    background: var(--accent);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
    line-height: 1.4;
}

.account-item .account-actions {
    opacity: 0;
    transition: var(--transition);
}
.account-item:hover .account-actions { opacity: 1; }

.all-accounts-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.all-accounts-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.all-accounts-item.active { background: var(--bg-active); color: var(--accent); }

.all-accounts-dots {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.all-accounts-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    display: block;
}

/* Folder Navigation */
.folder-nav {
    padding: 0.5rem 0.75rem;
    flex: 1;
    overflow-y: auto;
}

.folder-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    margin-bottom: 1px;
    position: relative;
}

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

.folder-item.active {
    background: var(--bg-active);
    color: var(--accent);
    font-weight: 500;
}

.folder-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 25%;
    bottom: 25%;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.folder-item svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

.folder-item span {
    flex: 1;
    font-size: 0.85rem;
}

.folder-badge {
    font-size: 0.72rem;
    color: var(--accent);
    font-weight: 600;
    background: var(--accent-light);
    padding: 0.05rem 0.45rem;
    border-radius: var(--radius-full);
}

/* Quick Navigation */
.sidebar-section {
    padding: 0.5rem 0.75rem;
    border-top: 1px solid var(--border);
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-size: 0.85rem;
}

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

.sidebar-nav-item.active {
    background: var(--bg-active);
    color: var(--accent);
}

.sidebar-nav-item svg {
    width: 17px;
    height: 17px;
    flex-shrink: 0;
}

/* Storage indicator */
.storage-indicator {
    padding: 0.75rem;
    margin: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.storage-bar {
    height: 4px;
    background: var(--bg-primary);
    border-radius: var(--radius-full);
    margin-top: 0.5rem;
    overflow: hidden;
}

.storage-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

.storage-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.sidebar-user:hover { background: var(--bg-hover); }

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
    color: white;
    flex-shrink: 0;
    position: relative;
}

.user-avatar.online::after {
    content: '';
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    background: var(--success);
    border: 2px solid var(--bg-sidebar);
    border-radius: 50%;
}

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

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

.user-status {
    font-size: 0.72rem;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.user-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    display: inline-block;
}

/* =============================================
   Main Content Area
   ============================================= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    position: relative;
}

/* =============================================
   Toolbar
   ============================================= */
.toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    min-height: var(--toolbar-height);
    flex-shrink: 0;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.toolbar-center {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 1rem;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 0.25rem;
}

/* Search */
.search-box {
    position: relative;
    width: 100%;
    max-width: 480px;
}

.search-box svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 17px;
    height: 17px;
    color: var(--text-muted);
    pointer-events: none;
    transition: var(--transition);
}

.search-box input {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 2.75rem;
    background: var(--bg-primary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-family: var(--font);
    outline: none;
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: var(--bg-secondary);
}

.search-box input:focus + svg,
.search-box:focus-within svg {
    color: var(--accent);
}

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

.search-shortcut {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-family: var(--font-mono);
    pointer-events: none;
}

/* =============================================
   Content Panels (Split View)
   ============================================= */
.content-panels {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* Email List Panel */
.email-list-panel {
    width: 400px;
    min-width: 300px;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--bg-primary);
    transition: width 0.3s ease;
}

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

.email-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1.1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    min-height: 42px;
    flex-shrink: 0;
}

.email-list-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.email-list-actions {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

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

/* Tabs for filtering */
.email-tabs {
    display: flex;
    padding: 0 1rem;
    gap: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.email-tab {
    padding: 0.6rem 1rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    position: relative;
}

.email-tab:hover { color: var(--text-primary); }

.email-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.email-tab .tab-badge {
    font-size: 0.65rem;
    background: var(--danger);
    color: white;
    padding: 0.05rem 0.35rem;
    border-radius: var(--radius-full);
    margin-left: 0.35rem;
    font-weight: 600;
}

/* Email Item */
.email-item {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.75rem 1.1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
}

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

.email-item.active,
.email-item.selected {
    background: var(--bg-active);
}

.email-item.active::before,
.email-item.selected::before {
    content: '';
    position: absolute;
    right: 0;
    top: 25%;
    bottom: 25%;
    width: 3px;
    background: var(--accent);
    border-radius: 3px 0 0 3px;
}

.email-item.unread {
    background: var(--bg-secondary);
}

.email-item.unread .email-sender {
    font-weight: 600;
    color: var(--text-primary);
}

.email-item.unread .email-subject {
    font-weight: 600;
    color: var(--text-primary);
}

.email-item.unread::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
}

.email-item-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding-top: 2px;
}

.email-item-avatar {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.82rem;
    color: white;
    flex-shrink: 0;
}

.email-account-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 6px;
}

.email-star {
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
    display: flex;
    margin-top: 2px;
}

.email-star:hover { color: var(--warning); transform: scale(1.1); }
.email-star.active { color: var(--warning); }
.email-star svg { width: 15px; height: 15px; }

.email-content {
    flex: 1;
    min-width: 0;
}

.email-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.1rem;
}

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

.email-date {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.email-subject {
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.1rem;
    font-weight: 400;
}

.email-preview {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.email-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
    flex-shrink: 0;
}

.email-attachment-icon {
    color: var(--text-muted);
}
.email-attachment-icon svg { width: 13px; height: 13px; }

.email-tags {
    display: flex;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.email-tag {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.email-tag-account {
    background: var(--accent-light);
    color: var(--accent);
}

.email-item-icons {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
    color: var(--text-muted);
}

.email-item-icons svg { width: 13px; height: 13px; }

/* =============================================
   Email Reading Pane
   ============================================= */
.email-reading-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-width: 0;
}

.email-reading-pane.empty {
    align-items: center;
    justify-content: center;
}

.email-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.email-view-toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0 1.1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    min-height: 42px;
    flex-shrink: 0;
}

.email-view-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.email-view-toolbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.email-view-header {
    padding: 1.25rem 1.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.email-view-subject {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.35;
    letter-spacing: -0.01em;
}

.email-view-labels {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.email-label {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.label-inbox { background: var(--info-light); color: var(--info); }
.label-important { background: var(--warning-light); color: var(--warning); }

.email-view-meta {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.email-view-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
}

.email-view-from {
    flex: 1;
    min-width: 0;
}

.email-view-sender {
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.email-view-sender .verified-badge {
    color: var(--info);
}

.email-view-sender .verified-badge svg { width: 15px; height: 15px; }

.email-view-email-addr {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.email-view-recipients {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.email-view-toggle-details {
    font-size: 0.75rem;
    color: var(--accent);
    cursor: pointer;
    margin-top: 0.15rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.email-view-toggle-details:hover { text-decoration: underline; }
.email-view-toggle-details svg { width: 12px; height: 12px; }

.email-view-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    flex-shrink: 0;
    text-align: right;
}

.email-view-date-relative {
    font-weight: 500;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.15rem;
}

/* Email Body */
.email-view-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.75rem;
}

.email-view-body iframe {
    width: 100%;
    border: none;
    min-height: 300px;
    border-radius: var(--radius-sm);
}

.email-view-text {
    white-space: pre-wrap;
    font-size: 0.93rem;
    line-height: 1.8;
    color: var(--text-primary);
    max-width: 720px;
}

/* Attachments */
.email-view-attachments {
    padding: 0.85rem 1.75rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.attachments-header {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-secondary);
}

.attachments-header svg { width: 15px; height: 15px; }

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.attachment-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.attachment-item svg { width: 16px; height: 16px; }

.attachment-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.attachment-icon.pdf { background: var(--danger-light); color: var(--danger); }
.attachment-icon.img { background: var(--success-light); color: var(--success); }
.attachment-icon.doc { background: var(--info-light); color: var(--info); }
.attachment-icon.default { background: var(--bg-tertiary); color: var(--text-muted); }

.attachment-info { flex: 1; min-width: 0; }
.attachment-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attachment-size { font-size: 0.7rem; color: var(--text-muted); }

/* Quick Reply */
.quick-reply {
    padding: 0.85rem 1.75rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.quick-reply-input {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
}

.quick-reply-input textarea {
    flex: 1;
    padding: 0.6rem 0.85rem;
    background: var(--bg-input);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.88rem;
    resize: none;
    outline: none;
    min-height: 40px;
    max-height: 120px;
    transition: var(--transition);
}

.quick-reply-input textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.quick-reply-input textarea::placeholder { color: var(--text-muted); }

/* =============================================
   Compose Modal
   ============================================= */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: overlayIn 0.15s ease;
}

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

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: modalIn 0.2s ease;
    overflow: hidden;
}

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

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

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

.modal-title {
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-title svg {
    width: 20px;
    height: 20px;
    color: var(--accent);
}

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

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

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

.compose-field-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    min-width: 32px;
}

.compose-field input, .compose-field select {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font);
    outline: none;
    padding: 0.25rem 0;
}

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

.compose-body {
    width: 100%;
    min-height: 250px;
    padding: 1rem 0;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.93rem;
    line-height: 1.7;
    resize: none;
    outline: none;
}

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

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

/* =============================================
   Account Form Improvements
   ============================================= */
.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.form-section-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 1.25rem 0 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-section-title svg { width: 16px; height: 16px; color: var(--accent); }

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.color-picker {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    background: none;
}

.preset-colors {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.preset-color {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    border: 2.5px solid transparent;
    transition: var(--transition);
}

.preset-color:hover, .preset-color.active {
    border-color: var(--text-primary);
    transform: scale(1.15);
}

/* Provider Quick Select */
.provider-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    margin-bottom: 1.25rem;
}

.provider-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.75rem 0.5rem;
    background: var(--bg-tertiary);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.provider-card:hover {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.provider-card.active {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
}

.provider-card svg { width: 22px; height: 22px; }

/* Connection status indicator */
.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    margin-top: 0.75rem;
}

.connection-status.success {
    background: var(--success-light);
    color: var(--success);
    border: 1px solid rgba(5,150,105,0.15);
}

.connection-status.error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid rgba(220,38,38,0.15);
}

.connection-status.testing {
    background: var(--info-light);
    color: var(--info);
    border: 1px solid rgba(37,99,235,0.15);
}

.connection-status svg { width: 16px; height: 16px; flex-shrink: 0; }

/* =============================================
   Loading & Empty States
   ============================================= */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    gap: 1rem;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 2.5px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-sm { width: 16px; height: 16px; border-width: 2px; }

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

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
    text-align: center;
}

.empty-state-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.empty-state-icon svg {
    width: 32px;
    height: 32px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.empty-state p {
    font-size: 0.88rem;
    max-width: 340px;
    line-height: 1.5;
}

/* =============================================
   Pagination
   ============================================= */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.75rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.pagination-info {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-right: auto;
}

.pagination-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
}

.pagination-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.pagination-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.pagination-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

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

.pagination-ellipsis {
    padding: 0 0.35rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* =============================================
   Toast Notifications
   ============================================= */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    max-width: 380px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 0.85rem;
    color: var(--text-primary);
    animation: toastIn 0.3s ease;
    position: relative;
    overflow: hidden;
}

.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
}

.toast.success::before { background: var(--success); }
.toast.error::before { background: var(--danger); }
.toast.warning::before { background: var(--warning); }
.toast.info::before { background: var(--info); }

.toast-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast.success .toast-icon { background: var(--success-light); color: var(--success); }
.toast.error .toast-icon { background: var(--danger-light); color: var(--danger); }
.toast.warning .toast-icon { background: var(--warning-light); color: var(--warning); }
.toast.info .toast-icon { background: var(--info-light); color: var(--info); }

.toast-icon svg { width: 15px; height: 15px; }

.toast-content { flex: 1; }
.toast-title { font-weight: 600; font-size: 0.85rem; }
.toast-message { font-size: 0.78rem; color: var(--text-secondary); margin-top: 0.1rem; }

.toast-close {
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    padding: 0.2rem;
}
.toast-close:hover { color: var(--text-primary); }
.toast-close svg { width: 14px; height: 14px; }

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
}

.toast-progress-bar {
    height: 100%;
    background: var(--accent);
    width: 100%;
    transition: width 4s linear;
}

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

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

/* =============================================
   Settings Page
   ============================================= */
.settings-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
}

.settings-nav {
    width: 220px;
    min-width: 220px;
    border-right: 1px solid var(--border);
    padding: 1.25rem 0.75rem;
    overflow-y: auto;
    background: var(--bg-secondary);
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-bottom: 2px;
}

.settings-nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.settings-nav-item.active { background: var(--bg-active); color: var(--accent); font-weight: 500; }
.settings-nav-item svg { width: 18px; height: 18px; }

.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.settings-container {
    max-width: 640px;
}

.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.settings-section-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-section-title svg {
    width: 20px;
    height: 20px;
    color: var(--accent);
}

/* =============================================
   Contacts / Address Book
   ============================================= */
.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    padding: 1.5rem;
}

.contact-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: var(--transition);
    cursor: pointer;
}

.contact-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
}

.contact-card-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 0.85rem;
}

.contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 1rem;
}

.contact-name { font-weight: 600; font-size: 0.95rem; }
.contact-company { font-size: 0.78rem; color: var(--text-muted); }

.contact-detail {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 0.35rem;
}

.contact-detail svg { width: 14px; height: 14px; color: var(--text-muted); }

/* =============================================
   Dropdown Menu
   ============================================= */
.dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 500;
    padding: 0.35rem;
    animation: dropIn 0.1s ease;
}

@keyframes dropIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown.open .dropdown-menu { display: block; }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

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

.dropdown-item svg { width: 16px; height: 16px; }

.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-light); }

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.25rem 0;
}

/* =============================================
   Tooltip
   ============================================= */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 0.3rem 0.6rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 0.72rem;
    color: var(--text-secondary);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.15s ease;
    z-index: 600;
    box-shadow: var(--shadow);
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* =============================================
   Keyboard Shortcut Hints
   ============================================= */
.kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 0.4rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.68rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    box-shadow: 0 1px 0 var(--border-light);
}

/* =============================================
   Context Menu
   ============================================= */
.context-menu {
    position: fixed;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    padding: 0.35rem;
    animation: dropIn 0.1s ease;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.65rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

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

.context-menu-item svg { width: 15px; height: 15px; }
.context-menu-item .shortcut {
    margin-left: auto;
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* =============================================
   Badge / Chip
   ============================================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.55rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-primary { background: var(--accent-light); color: var(--accent); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-neutral { background: var(--bg-tertiary); color: var(--text-secondary); }

.badge svg { width: 12px; height: 12px; }

/* =============================================
   Signature Editor
   ============================================= */
.signature-editor {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.signature-toolbar {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    padding: 0.35rem 0.5rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.signature-content {
    min-height: 150px;
    padding: 0.75rem;
    font-family: var(--font);
    font-size: 0.88rem;
    color: var(--text-primary);
    outline: none;
    line-height: 1.6;
}

/* =============================================
   Mail Rules / Filters
   ============================================= */
.rule-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rule-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.rule-item:hover {
    border-color: var(--border-light);
}

.rule-item-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rule-item-content {
    flex: 1;
    min-width: 0;
}

.rule-item-name {
    font-size: 0.88rem;
    font-weight: 500;
}

.rule-item-desc {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.rule-item-actions {
    display: flex;
    gap: 0.25rem;
}

/* =============================================
   Forward Modal
   ============================================= */
.forward-original {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-height: 200px;
    overflow-y: auto;
}

.forward-original-header {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* =============================================
   Responsive
   ============================================= */
.mobile-toggle {
    display: none;
}

@media (max-width: 1024px) {
    .email-list-panel {
        width: 340px;
        min-width: 280px;
    }

    .settings-nav { width: 200px; min-width: 200px; }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: calc(-1 * var(--sidebar-width));
        top: 0;
        bottom: 0;
        z-index: 1000;
        box-shadow: var(--shadow-xl);
    }

    .sidebar.open { left: 0; }

    .mobile-toggle { display: flex; }

    .mobile-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 999;
    }

    .mobile-overlay.active { display: block; }

    .content-panels { flex-direction: column; }

    .email-list-panel {
        width: 100% !important;
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .email-list-panel.full-width { flex: 1; }

    .email-reading-pane {
        position: fixed;
        inset: 0;
        z-index: 200;
        background: var(--bg-primary);
        display: none;
    }

    .email-reading-pane.active { display: flex; }

    .auth-card { padding: 2rem; }

    .form-row { flex-direction: column; gap: 0; }

    .email-view-subject { font-size: 1.15rem; }

    .email-view-body { padding: 1.25rem; }

    .provider-grid { grid-template-columns: repeat(2, 1fr); }

    .search-shortcut { display: none; }

    .modal { border-radius: 12px; margin: 1rem; max-height: 95vh; }

    .settings-layout { flex-direction: column; }
    .settings-nav { width: 100%; min-width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding: 0.75rem; display: flex; overflow-x: auto; gap: 0.25rem; }
    .settings-nav-item { white-space: nowrap; }

    .contacts-grid { grid-template-columns: 1fr; }

    .toolbar-center { display: none; }

    .toast-container { left: 1rem; right: 1rem; max-width: 100%; }
}

@media (max-width: 480px) {
    html { font-size: 14px; }
    .auth-card { padding: 1.5rem; border-radius: 14px; }
    .email-item { padding: 0.7rem 0.85rem; }
    .toolbar { padding: 0 0.75rem; }
}

/* =============================================
   Print Styles
   ============================================= */
@media print {
    .sidebar, .toolbar, .email-list-panel, .modal-overlay, .toast-container,
    .email-view-toolbar, .quick-reply, .pagination { display: none !important; }

    .email-reading-pane {
        position: static !important;
        display: flex !important;
    }

    .email-view-header { background: white; border: none; }
    .email-view-body { padding: 0; }

    body { background: white; color: black; }
}

/* =============================================
   Connection Indicator
   ============================================= */
.connection-indicator {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-full);
    transition: var(--transition);
    cursor: default;
    user-select: none;
}

.connection-indicator.online {
    color: var(--success);
    background: var(--success-light);
}

.connection-indicator.offline {
    color: var(--danger);
    background: var(--danger-light);
    animation: pulse-offline 2s ease-in-out infinite;
}

.connection-indicator .indicator-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.connection-indicator.online .indicator-dot {
    background: var(--success);
}

.connection-indicator.offline .indicator-dot {
    background: var(--danger);
}

@keyframes pulse-offline {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* =============================================
   Account Group Headers
   ============================================= */
.account-group-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    margin-top: 0.5rem;
    margin-bottom: 0.15rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.account-group-header:first-child {
    margin-top: 0;
}

.account-group-count {
    font-size: 0.62rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    padding: 0.05rem 0.35rem;
    border-radius: var(--radius-full);
    margin-left: auto;
    line-height: 1.4;
}

.account-email {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* =============================================
   Search Results Info
   ============================================= */
.search-results-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1.1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.search-results-info svg {
    color: var(--accent);
}

/* =============================================
   Folder Message Count
   ============================================= */
.folder-msg-count {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: auto;
    padding-left: 0.35rem;
}

/* =============================================
   Drag & Drop Folder Hover
   ============================================= */
.folder-item.drag-over {
    background: var(--accent-light);
    border-color: var(--accent);
    outline: 1.5px dashed var(--accent);
    outline-offset: -1.5px;
}

/* =============================================
   Utilities
   ============================================= */
.hidden { display: none !important; }
.invisible { visibility: hidden; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.72rem; }
.text-lg { font-size: 1.1rem; }
.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.w-full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }

.divider {
    height: 1px;
    background: var(--border);
    margin: 1.25rem 0;
}

.link-subtle {
    color: var(--text-muted);
    font-size: 0.88rem;
    transition: var(--transition);
}
.link-subtle:hover { color: var(--accent); }
.link-subtle strong { color: var(--accent); font-weight: 600; }

/* Focus visible for keyboard users */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
