/* ============================================================
   AdMkr AI — Design System
   Font: Plus Jakarta Sans (loaded in layout)
   Primary: #6C5CE7  Success: #00B894  Danger: #E17055
   ============================================================ */

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

:root {
    --primary:      #6C5CE7;
    --primary-dark: #5A4BD1;
    --primary-light:#EDE9FD;
    --success:      #00B894;
    --danger:       #E17055;
    --warning:      #FDCB6E;
    --info:         #0984E3;
    --bg:           #F8F9FC;
    --card-bg:      #FFFFFF;
    --border:       #E8ECF4;
    --text-1:       #111827;
    --text-2:       #374151;
    --text-3:       #6B7280;
    --text-4:       #9AA3B4;
    --sidebar-bg:   #1A1D2E;
    --sidebar-w:    220px;
    --topbar-h:     56px;
    --radius:       12px;
    --radius-sm:    8px;
    --shadow:       0 1px 4px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.06);
    --shadow-sm:    0 1px 3px rgba(0,0,0,.06);
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 14px;
    color: var(--text-1);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .25s ease;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid rgba(255,255,255,.07);
}

.logo-icon {
    width: 34px; height: 34px;
    background: var(--primary);
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.logo-text {
    font-size: 15.5px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.3px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    color: rgba(255,255,255,.55);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all .15s ease;
}

.nav-link:hover  { background: rgba(255,255,255,.07); color: rgba(255,255,255,.85); }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link.active .nav-icon { opacity: 1; }

.nav-icon { opacity: .7; flex-shrink: 0; }

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 14px;
    border-top: 1px solid rgba(255,255,255,.07);
}

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

.user-info { flex: 1; min-width: 0; }
.user-name-sm  { font-size: 12.5px; font-weight: 700; color: #fff;                     white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email-sm { font-size: 11px;   color: rgba(255,255,255,.4);                       white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.logout-btn {
    color: rgba(255,255,255,.35);
    transition: color .15s;
    flex-shrink: 0;
}
.logout-btn:hover { color: var(--danger); }

/* ── MAIN WRAPPER ────────────────────────────────────────── */
.main-wrapper {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-page  { font-size: 14px; font-weight: 700; color: var(--text-1); }
.sidebar-toggle { display: none; background: none; border: none; cursor: pointer; color: var(--text-2); padding: 4px; }

.topbar-avatar {
    width: 32px; height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff;
}

/* ── PAGE CONTENT ────────────────────────────────────────── */
.page-content {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

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

.page-header-left h1 {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-1);
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-header-left p {
    font-size: 13px;
    color: var(--text-4);
    margin-top: 3px;
}

.page-header-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

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

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow); }

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

.stat-body { flex: 1; }
.stat-value { font-size: 22px; font-weight: 800; color: var(--text-1); line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-4); margin-top: 3px; font-weight: 500; }
.stat-change { font-size: 12px; font-weight: 600; margin-top: 6px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── CARDS ───────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

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

.card-title  { font-size: 14px; font-weight: 700; color: var(--text-1); }
.card-body   { padding: 18px; }

/* ── AI BOX ──────────────────────────────────────────────── */
.ai-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    overflow: hidden;
}

.ai-box-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    background: #F8F9FC;
}

.ai-box-title { font-size: 13.5px; font-weight: 700; color: var(--text-1); }

.ai-output {
    min-height: 180px;
    padding: 18px;
    font-size: 13.5px;
    color: var(--text-2);
    line-height: 1.65;
    transition: opacity .2s;
}

.ai-output.loading { opacity: .5; font-style: italic; color: var(--text-4); }

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 9px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all .15s ease;
    line-height: 1;
    white-space: nowrap;
}

.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-secondary { background: #fff; color: var(--text-2); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: #C8D0E0; }

.btn-danger   { background: #FFF0EE; color: var(--danger); border-color: #FECECA; }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-success  { background: #E6FAF5; color: var(--success); border-color: #B8EFE0; }
.btn-success:hover { background: var(--success); color: #fff; }

.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── FORMS ───────────────────────────────────────────────── */
.form-group  { margin-bottom: 14px; }
.form-label  { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text-1);
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108,92,231,.12);
}

.form-control::placeholder { color: var(--text-4); }
select.form-control { cursor: pointer; }

/* ── ALERTS ──────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 16px;
    border: 1px solid transparent;
}

.alert-success { background: #E6FAF5; color: #00856B; border-color: #B8EFE0; }
.alert-danger  { background: #FFF0EE; color: #C0392B; border-color: #FECECA; }
.alert-info    { background: #EEF6FF; color: #1D65B8; border-color: #BFDBFE; }

/* ── TABLES ──────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-4);
    text-transform: uppercase;
    letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-2);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.campaign-table-row:hover td { background: #FAFBFF; }

/* ── BADGES ──────────────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}

.status-dot { width: 6px; height: 6px; border-radius: 50%; }

.status-active  { background: #E6FAF5; color: #00856B; }
.status-active  .status-dot { background: var(--success); }

.status-paused  { background: #FFF8E6; color: #B45309; }
.status-paused  .status-dot { background: var(--warning); }

.status-draft   { background: #F1F3F9; color: var(--text-3); }
.status-draft   .status-dot { background: var(--text-4); }

.platform-badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 700; }
.platform-meta-badge   { background: #EEF2FF; color: #3B4AC8; }
.platform-google-badge { background: #FFF0EE; color: #C0392B; }
.platform-both-badge   { background: #E6FAF5; color: #007A5A; }

/* ── CAMPAIGNS TOOLBAR ───────────────────────────────────── */
.campaigns-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: 9px;
    padding: 7px 12px;
    flex: 1;
    max-width: 320px;
    transition: border-color .15s;
}

.search-box:focus-within { border-color: var(--primary); }
.search-box svg { color: var(--text-4); flex-shrink: 0; }
.search-box input { border: none; outline: none; font-family: inherit; font-size: 13.5px; color: var(--text-1); background: transparent; width: 100%; }

.chart-tab {
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-3);
    text-decoration: none;
    border: 1px solid var(--border);
    background: var(--card-bg);
    transition: all .15s;
}
.chart-tab:hover  { color: var(--text-1); border-color: #C8D0E0; }
.chart-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,15,30,.45);
    backdrop-filter: blur(3px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
    width: 100%;
    max-width: 480px;
    animation: modal-in .2s ease;
}

@keyframes modal-in {
    from { opacity: 0; transform: scale(.96) translateY(10px); }
    to   { opacity: 1; transform: scale(1)  translateY(0); }
}

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

.modal-title  { font-size: 15px; font-weight: 700; color: var(--text-1); }
.modal-close  { background: none; border: none; cursor: pointer; color: var(--text-4); padding: 4px; border-radius: 6px; transition: color .15s; }
.modal-close:hover { color: var(--danger); }
.modal-body   { padding: 20px 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-4);
}
.empty-state svg { margin: 0 auto 14px; display: block; }
.empty-state h3  { font-size: 16px; font-weight: 700; color: var(--text-3); margin-bottom: 6px; }
.empty-state p   { font-size: 13.5px; }

/* ── AUTH PAGES ──────────────────────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1A1D2E 0%, #2D2F45 100%);
    padding: 20px;
}

.auth-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 36px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 80px rgba(0,0,0,.25);
}

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

.auth-title    { font-size: 22px; font-weight: 800; color: var(--text-1); text-align: center; margin-bottom: 6px; }
.auth-subtitle { font-size: 13.5px; color: var(--text-4); text-align: center; margin-bottom: 24px; }
.auth-footer   { text-align: center; font-size: 13px; color: var(--text-4); margin-top: 20px; }
.auth-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }
.auth-footer a:hover { text-decoration: underline; }

/* ── QUICK ACTIONS GRID ──────────────────────────────────── */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.quick-action-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    transition: all .2s ease;
    box-shadow: var(--shadow-sm);
}

.quick-action-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 20px rgba(108,92,231,.12);
    transform: translateY(-2px);
}

.quick-action-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
}

.quick-action-label { font-size: 13px; font-weight: 700; color: var(--text-1); }
.quick-action-desc  { font-size: 12px; color: var(--text-4); }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .app-layout.sidebar-open .sidebar {
        transform: translateX(0);
    }
    .main-wrapper { margin-left: 0; }
    .sidebar-toggle { display: flex; }
    .page-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .auth-card { padding: 28px 22px; }
    .stats-grid { grid-template-columns: 1fr; }
}
