@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ─── Design Tokens ─────────────────────────────────────────────── */
:root {
    --bg:           #080c14;
    --surface-1:    #0d1117;
    --surface-2:    #161b26;
    --surface-3:    #1c2333;
    --border:       rgba(255,255,255,0.07);
    --border-glow:  rgba(99,102,241,0.4);

    --primary:      #6366f1;
    --primary-dim:  rgba(99,102,241,0.15);
    --purple:       #a855f7;
    --purple-dim:   rgba(168,85,247,0.15);
    --blue:         #3b82f6;
    --blue-dim:     rgba(59,130,246,0.15);
    --cyan:         #06b6d4;
    --cyan-dim:     rgba(6,182,212,0.12);
    --green:        #10b981;
    --green-dim:    rgba(16,185,129,0.12);
    --red:          #ef4444;
    --red-dim:      rgba(239,68,68,0.12);
    --amber:        #f59e0b;

    --text-1:       #f0f4ff;
    --text-2:       #8b92a5;
    --text-3:       #4e5566;

    --sidebar-w:    240px;
    --radius-sm:    6px;
    --radius:       10px;
    --radius-lg:    16px;
    --radius-xl:    22px;

    --shadow:       0 4px 24px rgba(0,0,0,0.5);
    --shadow-glow:  0 0 40px rgba(99,102,241,0.12);
}

/* ─── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text-1);
    min-height: 100vh;
    display: flex;
    overflow: auto;
}

/* ─── Background Orbs ────────────────────────────────────────────── */
body::before, body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    filter: blur(120px);
    opacity: 0.2;
    z-index: 0;
}
body::before {
    width: 600px; height: 600px;
    background: var(--primary);
    top: -200px; right: -100px;
}
body::after {
    width: 500px; height: 500px;
    background: var(--purple);
    bottom: -150px; left: -100px;
}

/* ─── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface-1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    z-index: 100;
    transition: transform 0.3s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 2rem;
}

.brand-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--purple));
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.brand-name {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-1);
}

.brand-name span {
    font-weight: 300;
    opacity: 0.6;
}

/* Nav sections */
.nav-section {
    margin-bottom: 1.5rem;
}

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-3);
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-links a, .nav-links button {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.18s ease;
    position: relative;
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    width: 100%;
    text-align: left;
}

.nav-links a .nav-icon { font-size: 1rem; opacity: 0.7; flex-shrink: 0; }

.nav-links a:hover {
    background: var(--surface-2);
    color: var(--text-1);
}

.nav-links a:hover .nav-icon { opacity: 1; }

.nav-links a.active {
    background: var(--primary-dim);
    color: #a5b4fc;
}

.nav-links a.active .nav-icon { opacity: 1; }
.nav-links a.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.nav-links button {
    color: var(--text-2);
    font-size: 0.875rem;
}
.nav-links button:hover { background: var(--surface-2); color: var(--red); }

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.webmail-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--purple));
    color: white !important;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    transition: opacity 0.2s;
    margin-bottom: 0.75rem;
}
.webmail-btn:hover { opacity: 0.85; }

/* ─── Main Content ───────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    padding: 2rem 2.5rem;
    position: relative;
    z-index: 1;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 200;
    }
    .main-content {
        margin-left: 0;
        padding: 1.25rem;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* ─── Page Header ────────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.page-header-left {}
.page-breadcrumb {
    font-size: 0.75rem;
    color: var(--text-3);
    margin-bottom: 0.25rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

/* Legacy .header compatibility */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}
.header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

/* ─── Stat Cards ─────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255,255,255,0.12);
}

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    border-radius: 50%;
    opacity: 0.08;
    transform: translate(30%, -30%);
}

.stat-card.indigo::after  { background: var(--primary); }
.stat-card.purple::after  { background: var(--purple); }
.stat-card.green::after   { background: var(--green); }
.stat-card.blue::after    { background: var(--blue); }
.stat-card.red::after     { background: var(--red); }

.stat-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.stat-card.indigo .stat-icon { background: var(--primary-dim); color: #a5b4fc; }
.stat-card.purple .stat-icon { background: var(--purple-dim); color: #d8b4fe; }
.stat-card.green  .stat-icon { background: var(--green-dim);  color: #6ee7b7; }
.stat-card.blue   .stat-icon { background: var(--blue-dim);   color: #93c5fd; }
.stat-card.red    .stat-icon { background: var(--red-dim);    color: #fca5a5; }

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
    margin-bottom: 0.3rem;
}

.stat-card.indigo .stat-value { color: #a5b4fc; }
.stat-card.purple .stat-value { color: #d8b4fe; }
.stat-card.green  .stat-value { color: #6ee7b7; }
.stat-card.blue   .stat-value { color: #93c5fd; }
.stat-card.red    .stat-value { color: #fca5a5; }

.stat-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-2);
    letter-spacing: 0.01em;
}

/* ─── Generic Card ───────────────────────────────────────────────── */
.card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: rgba(255,255,255,0.11);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-1);
}

.card-subtitle {
    font-size: 0.75rem;
    color: var(--text-3);
    margin-top: 0.15rem;
}

/* ─── Forms ──────────────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-2);
    letter-spacing: 0.01em;
}

input, select, textarea {
    background: var(--surface-1);
    border: 1px solid var(--border);
    color: var(--text-1);
    padding: 0.65rem 0.875rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.18s;
    width: 100%;
}

input::placeholder { color: var(--text-3); }

input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}

select option { background: var(--surface-2); }

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: all 0.18s ease;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.btn { background: var(--primary); color: white; }
.btn:hover { background: #4f46e5; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(99,102,241,0.4); }

.btn.secondary {
    background: var(--surface-3);
    color: var(--text-2);
    border: 1px solid var(--border);
}
.btn.secondary:hover { background: var(--surface-2); color: var(--text-1); transform: translateY(-1px); box-shadow: none; }

.btn.danger {
    background: var(--red-dim);
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.2);
}
.btn.danger:hover { background: var(--red); color: white; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(239,68,68,0.3); }

.btn.success {
    background: var(--green-dim);
    color: var(--green);
    border: 1px solid rgba(16,185,129,0.2);
}
.btn.success:hover { background: var(--green); color: white; }

.btn.sm { padding: 0.4rem 0.875rem; font-size: 0.8rem; }
.btn.icon-only { padding: 0.5rem; }

/* ─── Tables ─────────────────────────────────────────────────────── */
.table-wrapper {
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--surface-1);
}

th {
    padding: 0.75rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    color: var(--text-1);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
    transition: background 0.15s;
}
tbody tr:hover { background: rgba(255,255,255,0.025); }

/* ─── Badges ─────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.7rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge::before { content: ''; display: block; width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }

.badge.permanent { background: var(--green-dim); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.2); }
.badge.permanent::before { background: var(--green); }
.badge.disposable { background: var(--purple-dim); color: #d8b4fe; border: 1px solid rgba(168,85,247,0.2); }
.badge.disposable::before { background: var(--purple); }
.badge.ok { background: var(--green-dim); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.2); }
.badge.ok::before { background: var(--green); }
.badge.error { background: var(--red-dim); color: #fca5a5; border: 1px solid rgba(239,68,68,0.2); }
.badge.error::before { background: var(--red); }
.badge.warn { background: rgba(245,158,11,0.1); color: #fcd34d; border: 1px solid rgba(245,158,11,0.2); }
.badge.warn::before { background: var(--amber); }
.badge.catch-all { background: var(--cyan-dim); color: #67e8f9; border: 1px solid rgba(6,182,212,0.2); }
.badge.catch-all::before { background: var(--cyan); }

/* ─── Toggle ─────────────────────────────────────────────────────── */
.toggle-group {
    display: flex;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.toggle-option {
    flex: 1;
    padding: 0.6rem 1rem;
    cursor: pointer;
    color: var(--text-2);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.18s;
    text-align: center;
    user-select: none;
}

.toggle-option.active {
    background: var(--primary-dim);
    color: #a5b4fc;
}

/* Legacy toggle-wrapper compat */
.toggle-wrapper {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}
.toggle-wrapper .toggle-option {
    padding: 0.6rem 1.25rem;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    flex: unset;
}

/* ─── Code Block ─────────────────────────────────────────────────── */
.code-block {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    font-family: 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.8rem;
    color: #93c5fd;
    word-break: break-all;
    line-height: 1.6;
    position: relative;
}

/* ─── Inbox Split View ───────────────────────────────────────────── */
.inbox-container {
    display: flex;
    gap: 1.25rem;
    height: calc(100vh - 120px);
}

.email-list {
    width: 320px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow-y: auto;
    flex-shrink: 0;
}

.email-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}
.email-item:hover { background: var(--surface-3); }
.email-item.active { background: var(--primary-dim); border-left: 3px solid var(--primary); }

.email-subject {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.email-sender {
    font-size: 0.75rem;
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-content {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    overflow-y: auto;
}

/* ─── Activity Feed (home) ───────────────────────────────────────── */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }

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

.activity-dot.green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.activity-dot.blue  { background: var(--blue);  box-shadow: 0 0 8px var(--blue);  }
.activity-dot.red   { background: var(--red);   box-shadow: 0 0 8px var(--red);   }
.activity-dot.purple { background: var(--purple); box-shadow: 0 0 8px var(--purple); }

.activity-text { font-size: 0.8rem; color: var(--text-2); line-height: 1.5; }
.activity-time { font-size: 0.72rem; color: var(--text-3); margin-top: 2px; }

/* ─── Alert banners ──────────────────────────────────────────────── */
.alert {
    padding: 0.875rem 1.125rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.alert.success { background: var(--green-dim); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.25); }
.alert.error   { background: var(--red-dim);   color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }
.alert.info    { background: var(--primary-dim); color: #a5b4fc; border: 1px solid rgba(99,102,241,0.25); }

/* ─── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ─── Animations ─────────────────────────────────────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fade-up { animation: fadeUp 0.4s ease forwards; }
