/* ================================================================
   BFS PRO Emails — Design System
   Primary bg: #F8FAFC | Accent: #4F46E5
================================================================ */

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

:root {
    --bg:          #F8FAFC;
    --surface:     #FFFFFF;
    --surface-2:   #F1F5F9;
    --border:      #E2E8F0;
    --border-2:    #CBD5E1;
    --text:        #0F172A;
    --text-2:      #475569;
    --text-3:      #94A3B8;
    --accent:      #4F46E5;
    --accent-h:    #4338CA;
    --accent-light:#EEF2FF;
    --success:     #10B981;
    --success-l:   #D1FAE5;
    --warning:     #F59E0B;
    --warning-l:   #FEF3C7;
    --danger:      #EF4444;
    --danger-l:    #FEE2E2;
    --info:        #3B82F6;
    --info-l:      #DBEAFE;
    --sidebar-w:   240px;
    --radius:      10px;
    --radius-lg:   14px;
    --shadow:      0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:   0 4px 12px rgba(0,0,0,.08);
    --transition:  150ms ease;
}

html { font-size: 15px; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Typography ─────────────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p  { color: var(--text-2); line-height: 1.7; }

/* ── Layout ─────────────────────────────────────────────────── */
.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}

.main-content {
    padding: 32px;
    overflow-y: auto;
    max-width: 1200px;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-logo-icon {
    width: 34px; height: 34px;
    background: var(--accent);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
}

.sidebar-logo-icon svg { width: 18px; height: 18px; fill: #fff; }

.sidebar-logo span {
    font-weight: 700;
    font-size: .95rem;
    color: var(--text);
    line-height: 1.2;
}

.sidebar-logo small {
    display: block;
    font-size: .65rem;
    color: var(--text-3);
    font-weight: 400;
}

.sidebar-nav { flex: 1; padding: 12px 10px; }

.nav-group { margin-bottom: 20px; }

.nav-label {
    font-size: .68rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 4px 10px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--text-2);
    font-size: .88rem;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
    text-decoration: none;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

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

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

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: .62rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid var(--border);
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition);
}

.user-chip:hover { background: var(--surface-2); }

.user-avatar {
    width: 32px; height: 32px;
    background: var(--accent);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; color: #fff;
    flex-shrink: 0;
}

.user-chip-info { flex: 1; min-width: 0; }
.user-chip-name  { font-size: .82rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip-email { font-size: .7rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Page header ────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
}

.page-header-left h1 { margin-bottom: 2px; }
.page-header-left p  { font-size: .875rem; margin: 0; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.card-body { padding: 24px; }
.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 { margin: 0; }

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

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.purple { background: #EDE9FE; color: #7C3AED; }
.stat-icon.blue   { background: #DBEAFE; color: #2563EB; }
.stat-icon.green  { background: #D1FAE5; color: #059669; }
.stat-icon.amber  { background: #FEF3C7; color: #D97706; }

.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: .8rem; color: var(--text-3); font-weight: 500; }
.stat-delta { font-size: .75rem; font-weight: 600; margin-top: 4px; }
.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 1px 3px rgba(79,70,229,.3);
}
.btn-primary:hover { background: var(--accent-h); text-decoration: none; color: #fff; }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-2);
}
.btn-secondary:hover { background: var(--surface-2); text-decoration: none; }

.btn-danger  { background: var(--danger);  color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm      { padding: 6px 12px; font-size: .8rem; }
.btn-lg      { padding: 12px 24px; font-size: 1rem; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

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

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-2);
    border-radius: 8px;
    font-size: .9rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    font-family: inherit;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.form-control::placeholder { color: var(--text-3); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint { font-size: .78rem; color: var(--text-3); margin-top: 5px; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: 5px; font-weight: 500; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

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

thead th {
    text-align: left;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: .875rem;
    color: var(--text);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ── Badges / Pills ─────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: var(--success-l); color: #065F46; }
.badge-warning { background: var(--warning-l); color: #92400E; }
.badge-danger  { background: var(--danger-l);  color: #991B1B; }
.badge-info    { background: var(--info-l);    color: #1E40AF; }
.badge-neutral { background: var(--surface-2); color: var(--text-2); }
.badge-accent  { background: var(--accent-light); color: var(--accent); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    padding: 13px 18px;
    border-radius: 8px;
    font-size: .875rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: var(--success-l); color: #065F46; border: 1px solid #A7F3D0; }
.alert-error   { background: var(--danger-l);  color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: var(--warning-l); color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: var(--info-l);    color: #1E40AF; border: 1px solid #BFDBFE; }

/* ── Progress bar ───────────────────────────────────────────── */
.progress-bar {
    height: 6px;
    background: var(--surface-2);
    border-radius: 99px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 99px;
    transition: width .3s ease;
}

/* ── Auth pages ─────────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0,0,0,.07);
    padding: 40px;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

.auth-logo-icon {
    width: 40px; height: 40px;
    background: var(--accent);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}

.auth-logo-icon svg { width: 22px; height: 22px; fill: #fff; }
.auth-logo-name { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.auth-logo-sub  { font-size: .7rem; color: var(--text-3); }

.auth-title    { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.auth-subtitle { font-size: .875rem; color: var(--text-2); margin-bottom: 28px; }

.auth-footer { margin-top: 22px; text-align: center; font-size: .84rem; color: var(--text-2); }
.auth-footer a { color: var(--accent); font-weight: 600; }

/* ── Divider ────────────────────────────────────────────────── */
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-3);
    font-size: .8rem;
}

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

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-3);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: .4; }
.empty-state h3  { color: var(--text-2); margin-bottom: 8px; }
.empty-state p   { font-size: .875rem; margin-bottom: 20px; }

/* ── Utility ────────────────────────────────────────────────── */
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.gap-4       { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm   { font-size: .875rem; }
.text-xs   { font-size: .78rem; }
.text-muted { color: var(--text-3); }
.text-right { text-align: right; }
.fw-600    { font-weight: 600; }
.w-full    { width: 100%; }
.grid-2    { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3    { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; }
.rounded   { border-radius: var(--radius); }
.truncate  { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
    .app-layout { grid-template-columns: 1fr; }
    .sidebar    { display: none; }
    .main-content { padding: 20px 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
