/* Meta Ads Insights — Theme inspired by Meta Ads Manager / GA4 */

:root {
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --bg-body: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #1b1f23;
    --text-primary: #1c1e21;
    --text-secondary: #65676b;
    --text-muted: #8a8d91;
    --border-color: #e4e6eb;
    --primary: #1877f2;
    --success: #31a24c;
    --danger: #fa383e;
    --warning: #f7b928;
    --info: #45bd62;
    --shadow: 0 1px 2px rgba(0,0,0,.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.1);
    --radius: 12px;
}

.dark-theme {
    --bg-body: #18191a;
    --bg-card: #242526;
    --bg-sidebar: #0d0e0f;
    --text-primary: #e4e6eb;
    --text-secondary: #b0b3b8;
    --text-muted: #8a8d91;
    --border-color: #3e4042;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    transition: background .2s, color .2s;
}

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #e4e6eb;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .75rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand i { color: var(--primary); font-size: 1.4rem; }

.sidebar-nav { padding: 1rem 0; flex: 1; }

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1.5rem;
    color: #b0b3b8;
    text-decoration: none;
    font-size: .9rem;
    transition: all .15s;
}

.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-link.active { background: rgba(24,119,242,.15); color: #fff; border-right: 3px solid var(--primary); }
.sidebar-link i { font-size: 1.1rem; width: 1.25rem; text-align: center; }
.sidebar-divider { border-color: rgba(255,255,255,.08); margin: .5rem 1.5rem; }

.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title { font-size: 1.25rem; font-weight: 600; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: .5rem; }

.app-content { flex: 1; }

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

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.25rem;
}

.chart-card .card-body { padding: .5rem 1rem 1rem; }

/* KPI Cards */
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    transition: transform .15s, box-shadow .15s;
    height: 100%;
}

.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

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

.kpi-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}

.kpi-primary .kpi-icon { background: rgba(24,119,242,.12); color: var(--primary); }
.kpi-success .kpi-icon { background: rgba(49,162,76,.12); color: var(--success); }
.kpi-danger .kpi-icon { background: rgba(250,56,62,.12); color: var(--danger); }
.kpi-warning .kpi-icon { background: rgba(247,185,40,.12); color: var(--warning); }
.kpi-info .kpi-icon { background: rgba(69,189,98,.12); color: var(--info); }
.kpi-secondary .kpi-icon { background: rgba(101,103,107,.12); color: var(--text-secondary); }

.kpi-trend { font-size: .8rem; font-weight: 600; display: flex; align-items: center; }
.trend-up { color: var(--success); }
.trend-down { color: var(--danger); }

.kpi-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.kpi-label { font-size: .85rem; color: var(--text-secondary); margin-top: .25rem; }
.kpi-sparkline { height: 40px; margin-top: .5rem; }

/* Auth */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1877f2 0%, #0d47a1 100%);
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-brand i { font-size: 2.5rem; color: var(--primary); }
.auth-brand h2 { margin: .5rem 0 0; font-size: 1.5rem; }

/* Utilities */
.btn-ghost { background: transparent; border: none; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--border-color); color: var(--text-primary); }

.avatar-sm {
    display: inline-flex;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: .7rem;
    font-weight: 600;
    align-items: center;
    justify-content: center;
    margin-right: .25rem;
}

.dark-theme .form-control,
.dark-theme .form-select {
    background: #3a3b3c;
    border-color: #3e4042;
    color: var(--text-primary);
}

.dark-theme .btn-outline-secondary {
    border-color: #3e4042;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .app-main { margin-left: 0; }
}
