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

/* ═══════════════════════════════════════════════════
   MailVibee Design System — v2.0
   Premium SaaS UI Kit
   ═══════════════════════════════════════════════════ */

:root {
    /* ── Core Palette ── */
    --bg: #F7F8FC;
    --bg-alt: #EEEEF5;
    --surface: #FFFFFF;
    --surface-raised: #FFFFFF;
    --surface-sunken: #F3F4F8;
    --border: #E4E5EB;
    --border-light: #EEEFF3;
    --border-focus: #6C5CE7;

    /* ── Brand ── */
    --brand: #6C5CE7;
    --brand-hover: #5A49D6;
    --brand-light: #F0EEFF;
    --brand-glow: rgba(108, 92, 231, 0.08);
    --brand-ring: rgba(108, 92, 231, 0.25);

    /* ── Text ── */
    --text: #1C1C28;
    --text-secondary: #555770;
    --text-tertiary: #8E90A6;
    --text-on-brand: #FFFFFF;

    /* ── Semantic ── */
    --success: #0D9F6E;
    --success-bg: #ECFDF5;
    --success-border: #D1FAE5;
    --error: #E02D3C;
    --error-bg: #FEF2F2;
    --error-border: #FEE2E2;
    --warning: #D97706;
    --warning-bg: #FFFBEB;
    --warning-border: #FEF3C7;
    --info: #2563EB;
    --info-bg: #EFF6FF;
    --info-border: #DBEAFE;

    /* ── Sidebar ── */
    --sidebar-bg: #18181F;
    --sidebar-surface: rgba(255,255,255,0.04);
    --sidebar-text: #A9ABB8;
    --sidebar-text-dim: #5E6073;
    --sidebar-hover: rgba(255,255,255,0.06);
    --sidebar-active-bg: rgba(108, 92, 231, 0.12);
    --sidebar-active-text: #B4A7FF;
    --sidebar-border: rgba(255,255,255,0.06);

    /* ── Layout ── */
    --sidebar-width: 256px;
    --radius-xs: 6px;
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* ── Shadows ── */
    --shadow-xs: 0 1px 2px rgba(16,24,40,0.05);
    --shadow-sm: 0 1px 3px rgba(16,24,40,0.06), 0 1px 2px rgba(16,24,40,0.04);
    --shadow: 0 4px 8px -2px rgba(16,24,40,0.06), 0 2px 4px -2px rgba(16,24,40,0.04);
    --shadow-md: 0 12px 24px -4px rgba(16,24,40,0.08), 0 4px 8px -2px rgba(16,24,40,0.04);
    --shadow-lg: 0 20px 40px -8px rgba(16,24,40,0.10);
    --shadow-brand: 0 4px 14px rgba(108, 92, 231, 0.25);

    /* ── Transitions ── */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand); text-decoration: none; transition: color 0.15s var(--ease); }
a:hover { color: var(--brand-hover); }

code, .mono {
    font-family: 'JetBrains Mono', 'SF Mono', monospace;
    font-size: 0.85em;
    background: var(--surface-sunken);
    padding: 2px 7px;
    border-radius: 5px;
    color: var(--brand);
}

::selection { background: var(--brand-light); color: var(--brand); }

/* ═══════════════════════════════════════
   AUTH PAGES
   ═══════════════════════════════════════ */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--bg);
    position: relative;
}
.auth-wrapper::before {
    content: '';
    position: absolute;
    top: -200px;
    right: -200px;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(108,92,231,0.06) 0%, transparent 70%);
    pointer-events: none;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 44px;
    width: 100%;
    max-width: 430px;
    box-shadow: var(--shadow);
    position: relative;
}
.auth-card h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.4px;
    margin-bottom: 4px;
}
.auth-card .subtitle {
    color: var(--text-tertiary);
    font-size: 14px;
    margin-bottom: 30px;
    line-height: 1.5;
}
.auth-card .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 32px;
}
.auth-card .logo-icon {
    width: 38px; height: 38px;
    background: var(--brand);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.auth-card .logo-icon svg { width: 20px; height: 20px; }
.auth-card .logo span {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.4px;
}
.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-tertiary);
}

/* ═══════════════════════════════════════
   APP SHELL — DASHBOARD LAYOUT
   ═══════════════════════════════════════ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    display: flex;
    flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 0; }

.sidebar .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--sidebar-border);
}
.sidebar .logo-icon {
    width: 32px; height: 32px;
    background: var(--brand);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.sidebar .logo-icon svg { width: 17px; height: 17px; }
.sidebar .logo span {
    font-size: 15px;
    font-weight: 700;
    color: #F0F0F5;
    letter-spacing: -0.2px;
}

.nav-section { padding: 14px 12px 4px; }
.nav-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.3px;
    color: var(--sidebar-text-dim);
    padding: 0 10px 8px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-xs);
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s var(--ease);
    text-decoration: none;
    margin-bottom: 1px;
}
.nav-item:hover {
    background: var(--sidebar-hover);
    color: #E0E0E8;
}
.nav-item.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
}
.nav-item .icon {
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    opacity: 0.55;
    flex-shrink: 0;
}
.nav-item.active .icon, .nav-item:hover .icon { opacity: 0.9; }
.nav-item .icon svg { width: 18px; height: 18px; }

.sidebar-footer {
    margin-top: auto;
    padding: 14px 18px;
    border-top: 1px solid var(--sidebar-border);
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 32px; height: 32px;
    border-radius: var(--radius-xs);
    background: rgba(108,92,231,0.15);
    color: var(--sidebar-active-text);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.user-info .name {
    font-weight: 600; color: #D5D6E0; font-size: 13px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;
}
.user-info .email-sm {
    font-size: 11px; color: var(--sidebar-text-dim);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px;
}

/* ── Main Content ── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px 40px 60px;
    max-width: 1060px;
}

/* ═══════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
}
.page-header h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
    line-height: 1.2;
}
.page-header p {
    color: var(--text-tertiary);
    font-size: 14px;
    margin-top: 4px;
}

/* ═══════════════════════════════════════
   CARDS
   ═══════════════════════════════════════ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.2s var(--ease);
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
}
.card-title {
    font-size: 15px;
    font-weight: 650;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ═══════════════════════════════════════
   FORMS
   ═══════════════════════════════════════ */
.form-row { display: flex; gap: 16px; margin-bottom: 16px; }
.form-row > * { flex: 1; min-width: 0; }
.form-group { margin-bottom: 18px; }

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], select, textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--brand-glow);
}
input::placeholder, textarea::placeholder { color: var(--text-tertiary); }

textarea {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.7;
    resize: vertical;
    min-height: 200px;
}
input[type="file"] { font-family: 'Outfit', sans-serif; font-size: 13px; cursor: pointer; }
input[type="checkbox"] { accent-color: var(--brand); cursor: pointer; }
select { cursor: pointer; }

/* ═══════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: 'Outfit', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s var(--ease);
    text-decoration: none;
    box-shadow: var(--shadow-xs);
    white-space: nowrap;
}
.btn:hover { background: var(--surface-sunken); border-color: #CCCDD5; color: var(--text); }
.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--text-on-brand);
    box-shadow: var(--shadow-brand);
}
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: var(--text-on-brand); }
.btn-danger { background: var(--error-bg); border-color: var(--error-border); color: var(--error); box-shadow: none; }
.btn-danger:hover { background: #FEE2E2; }
.btn-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); box-shadow: none; }
.btn-sm { padding: 6px 13px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ═══════════════════════════════════════
   TABLES
   ═══════════════════════════════════════ */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
    text-align: left;
    padding: 11px 16px;
    background: var(--surface-sunken);
    color: var(--text-tertiary);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
    font-size: 13px;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-sunken); }

/* ═══════════════════════════════════════
   BADGES
   ═══════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-xs);
    font-size: 11px;
    font-weight: 600;
}
.badge-accent { background: var(--brand-light); color: var(--brand); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-red { background: var(--error-bg); color: var(--error); }
.badge-yellow { background: var(--warning-bg); color: var(--warning); }
.badge-muted { background: var(--surface-sunken); color: var(--text-tertiary); }

/* ═══════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}
.stat-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.stat-value {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
    line-height: 1.1;
}
.stat-label {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 6px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* ═══════════════════════════════════════
   ALERTS
   ═══════════════════════════════════════ */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    line-height: 1.5;
}
.alert-success { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success); }
.alert-error { background: var(--error-bg); border: 1px solid var(--error-border); color: var(--error); }
.alert-warning { background: var(--warning-bg); border: 1px solid var(--warning-border); color: var(--warning); }
.alert-info { background: var(--info-bg); border: 1px solid var(--info-border); color: var(--info); }

/* ── Empty state ── */
.empty-state { padding: 52px 20px; text-align: center; color: var(--text-tertiary); }
.empty-state .icon { font-size: 44px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ── Template preview ── */
.template-preview {
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 24px;
    min-height: 200px;
    color: #333;
    border: 1px solid var(--border);
}

/* ── TinyMCE ── */
.tox-tinymce { border: 1px solid var(--border) !important; border-radius: var(--radius-sm) !important; }
.tox-notifications-container { display: none !important; }

/* ═══════════════════════════════════════
   HELPERS
   ═══════════════════════════════════════ */
.text-dim { color: var(--text-secondary); }
.text-muted { color: var(--text-tertiary); }
.text-brand { color: var(--brand); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.help-text { font-size: 12px; color: var(--text-tertiary); margin-top: 6px; line-height: 1.5; }

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 1024px) {
    .main-content { padding: 24px 24px 40px; }
}
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 16px; }
    .form-row { flex-direction: column; gap: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .auth-card { padding: 28px 22px; }
    .page-header { flex-direction: column; }
    .page-header h1 { font-size: 22px; }
    .btn-group { flex-direction: column; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}
