/* ============================================================
   SEO Coach — User Dashboard CSS — GoodBarber-inspired
   ============================================================ */

:root {
    /* Brand */
    --accent:          #FF5252;
    --accent-dark:     #E53935;
    --accent-light:    #FF867C;
    --accent-glow:     rgba(255,82,82,.08);
    /* UI Colors */
    --success:         #10b981;
    --warning:         #f59e0b;
    --danger:          #ef4444;
    --info:            #3b82f6;
    /* Light theme (default) */
    --bg:              #F9FAFB;
    --surface:         #FFFFFF;
    --surface2:        #F3F4F6;
    --surface3:        #E5E7EB;
    --text:            #111827;
    --text-muted:      #6B7280;
    --text-light:      #9CA3AF;
    --border:          #E5E7EB;
    --border-light:    #F3F4F6;
    /* Sidebar */
    --sidebar-bg:      #0f172a;
    --sidebar-text:    rgba(255,255,255,.88);
    --sidebar-active:  rgba(255,255,255,.18);
    --sidebar-hover:   rgba(255,255,255,.12);
    --sidebar-accent:  #FF5252;
    /* Typography */
    --font:            'DM Sans', -apple-system, system-ui, sans-serif;
    --font-display:    'Syne', sans-serif;
    /* Shape */
    --radius-sm:       6px;
    --radius-md:       10px;
    --radius-lg:       14px;
    --radius-xl:       20px;
    --radius-pill:     999px;
    /* Shadow */
    --shadow-sm:       0 1px 3px rgba(0,0,0,.06);
    --shadow-md:       0 4px 16px rgba(0,0,0,.07);
    --shadow-lg:       0 8px 32px rgba(0,0,0,.09);
    /* Layout */
    --sidebar-w:       240px;
    --topbar-h:        60px;
}

/* Dark mode */
[data-theme="dark"] {
    --bg:          #0d1117;
    --surface:     #161b22;
    --surface2:    #21262d;
    --surface3:    #30363d;
    --text:        #e6edf3;
    --text-muted:  #8b949e;
    --text-light:  #6e7681;
    --border:      #30363d;
    --border-light:#21262d;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { font-family: inherit; }

/* ── Layout ───────────────────────────────────────────────── */
.app-wrapper {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    min-height: 100vh;
}
.app-main {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
}
.app-content {
    flex: 1;
    padding: 28px 32px;
    max-width: 1280px;
    width: 100%;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    background: var(--sidebar-bg);
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-w); height: 100vh;
    display: flex; flex-direction: column;
    z-index: 100; overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.07);
    font-family: var(--font-display); font-weight: 800;
    font-size: .95rem; color: #fff; flex-shrink: 0;
}
.brand-icon {
    width: 30px; height: 30px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    border-radius: 8px; display: grid; place-items: center;
    color: #fff; font-size: .8rem; flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(255,82,82,.4);
}
.brand-name { color: #fff !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .95rem; font-weight: 800; }

/* Sidebar nav */
.sidebar-nav {
    flex: 1; padding: 10px 8px;
    display: flex; flex-direction: column; gap: 2px;
}
.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: var(--radius-md);
    color: #E2E8F0 !important; font-size: .875rem; font-weight: 500;
    transition: all .15s; cursor: pointer; white-space: nowrap;
    letter-spacing: .01em; text-decoration: none;
}
.nav-item span { color: #E2E8F0 !important; display: block; }
.nav-item:hover { background: rgba(255,255,255,.14); color: #fff !important; }
.nav-item:hover span { color: #fff !important; }
.nav-item.active {
    background: rgba(255,255,255,.16); color: #fff !important; font-weight: 700;
}
.nav-item.active span { color: #fff !important; }
.nav-item.active i { color: var(--sidebar-accent); }
.nav-item i { font-size: .85rem; width: 16px; text-align: center; flex-shrink: 0; }

/* Sidebar plan info */
.sidebar-plan {
    padding: 12px 10px;
    border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-plan-name {
    font-size: .7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .07em;
    color: rgba(255,255,255,.6); margin-bottom: 6px;
}
.plan-usage-bar {
    height: 4px; background: rgba(255,255,255,.1);
    border-radius: var(--radius-pill); margin-bottom: 4px; overflow: hidden;
}
.plan-usage-fill {
    height: 100%; background: var(--accent);
    border-radius: var(--radius-pill); transition: width .5s;
}
.plan-usage-label {
    font-size: .68rem; color: rgba(255,255,255,.55); margin-bottom: 8px;
}
.sidebar-upgrade {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 12px; background: rgba(255,82,82,.15);
    border: 1px solid rgba(255,82,82,.2); border-radius: var(--radius-md);
    color: #FF8A80; font-size: .78rem; font-weight: 700;
    transition: all .15s;
}
.sidebar-upgrade:hover { background: rgba(255,82,82,.25); }

/* Divider in sidebar */
.sidebar-divider {
    height: 1px; background: rgba(255,255,255,.12);
    margin: 8px 10px;
}
.sidebar-section-label {
    padding: 6px 12px 3px;
    font-size: .65rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .09em;
    color: rgba(255,255,255,.25);
}

/* Sidebar submenu */
.nav-item-group { display: flex; flex-direction: column; }
.nav-item-toggle { display: flex; align-items: center; width: 100%; background: none; border: none; cursor: pointer; }
.nav-toggle-icon { margin-left: auto; font-size: .6rem; transition: transform .2s; opacity: .5; }
.nav-submenu { display: none; margin: 2px 0 2px 26px; }
.nav-subitem {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 12px; border-radius: var(--radius-sm);
    font-size: .8rem; font-weight: 500;
    color: rgba(255,255,255,.7); transition: all .15s;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-subitem:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-subitem.active { color: var(--sidebar-accent); font-weight: 700; }

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 24px; gap: 12px;
    position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-weight: 700; font-size: .95rem; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.topbar-btn {
    width: 36px; height: 36px; border-radius: var(--radius-md);
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: .95rem;
    display: grid; place-items: center;
    transition: all .15s; position: relative;
}
.topbar-btn:hover { background: var(--surface2); color: var(--text); }
.notif-badge {
    position: absolute; top: 3px; right: 3px;
    background: var(--danger); color: #fff;
    font-size: .55rem; font-weight: 800;
    min-width: 16px; height: 16px; border-radius: var(--radius-pill);
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
}
.user-avatar {
    width: 32px; height: 32px; border-radius: var(--radius-pill);
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff; font-size: .8rem; font-weight: 800;
    display: grid; place-items: center; flex-shrink: 0;
}
.user-name { font-size: .835rem; font-weight: 600; color: var(--text-muted); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; border-bottom: 1px solid var(--border);
    flex-wrap: wrap; gap: 8px;
}
.card-title { font-weight: 700; font-size: .9rem; color: var(--text); }
.card-body { padding: 20px; }

/* ── Stats ────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 18px 20px;
    display: flex; align-items: center; gap: 14px;
    transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
    width: 44px; height: 44px; border-radius: var(--radius-md);
    display: grid; place-items: center; font-size: .95rem;
    flex-shrink: 0;
    background: var(--accent-glow); color: var(--accent);
}
.stat-icon.success { background: rgba(16,185,129,.1); color: var(--success); }
.stat-icon.warning { background: rgba(245,158,11,.1); color: var(--warning); }
.stat-icon.danger  { background: rgba(239,68,68,.1);  color: var(--danger); }
.stat-icon.info    { background: rgba(59,130,246,.1); color: var(--info); }
.stat-value { font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-muted); margin-top: 3px; font-weight: 500; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 8px 18px; border-radius: var(--radius-pill);
    font-weight: 700; font-size: .835rem; cursor: pointer;
    transition: all .18s; border: none; white-space: nowrap;
    font-family: var(--font);
}
.btn-primary {
    background: var(--accent); color: #fff;
    box-shadow: 0 2px 8px rgba(255,82,82,.25);
}
.btn-primary:hover {
    background: var(--accent-dark);
    box-shadow: 0 4px 14px rgba(255,82,82,.38);
    transform: translateY(-1px);
}
.btn-secondary {
    background: var(--surface2); color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface3); border-color: var(--text-light); }
.btn-danger  { background: rgba(239,68,68,.1); color: var(--danger); border: 1px solid rgba(239,68,68,.2); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: rgba(16,185,129,.1); color: var(--success); border: 1px solid rgba(16,185,129,.2); }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-outline  { background: transparent; border: 1.5px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-full  { width: 100%; justify-content: center; }
.btn-sm    { padding: 5px 13px; font-size: .78rem; }
.btn-xs    { padding: 4px 10px; font-size: .72rem; }
.btn-lg    { padding: 12px 26px; font-size: .95rem; }
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 10px; border-radius: var(--radius-pill);
    font-size: .7rem; font-weight: 700; white-space: nowrap;
}
.badge-accent  { background: var(--accent-glow);          color: var(--accent); }
.badge-success { background: rgba(16,185,129,.1);          color: var(--success); }
.badge-warning { background: rgba(245,158,11,.1);          color: var(--warning); }
.badge-danger  { background: rgba(239,68,68,.1);           color: var(--danger); }
.badge-info    { background: rgba(59,130,246,.1);          color: var(--info); }
.badge-muted   { background: var(--surface2);              color: var(--text-muted); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .845rem; }
th {
    padding: 10px 16px; text-align: left;
    font-size: .7rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-muted);
    background: var(--surface2); white-space: nowrap;
}
td { padding: 11px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: var(--surface2); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block; font-size: .7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-muted); margin-bottom: 5px;
}
.form-control {
    width: 100%; padding: 9px 12px;
    background: var(--surface2); border: 1.5px solid var(--border);
    border-radius: var(--radius-md); font-family: var(--font);
    font-size: .855rem; color: var(--text);
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255,82,82,.08);
    background: var(--surface);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: .73rem; color: var(--text-light); margin-top: 4px; }
.form-check {
    display: flex; align-items: center; gap: 8px;
    font-size: .855rem; cursor: pointer; color: var(--text-muted);
}

/* ── Flash ────────────────────────────────────────────────── */
.flash {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-radius: var(--radius-md);
    font-size: .855rem; font-weight: 500; margin-bottom: 16px;
}
.flash-success { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.2); color: var(--success); }
.flash-error   { background: rgba(255,82,82,.08); border: 1px solid rgba(255,82,82,.2);  color: var(--accent); }
.flash-warning { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.2); color: var(--warning); }
.flash-info    { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.2); color: var(--info); }

/* ── Page header ──────────────────────────────────────────── */
.page-header {
    display: flex; align-items: flex-start;
    justify-content: space-between; flex-wrap: wrap;
    gap: 12px; margin-bottom: 24px;
}
.page-header h2 {
    font-family: var(--font-display); font-size: 1.35rem;
    font-weight: 800; margin-bottom: 2px; letter-spacing: -.01em;
}
.page-header p { color: var(--text-muted); font-size: .845rem; }
.page-header-left { display: flex; flex-direction: column; gap: 2px; }

/* ── Grid helpers ─────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.flex    { display: flex; }
.gap-2   { gap: 8px; }
.gap-3   { gap: 12px; }
.mb-4    { margin-bottom: 16px; }
.mb-6    { margin-bottom: 24px; }
.mt-4    { margin-top: 16px; }

/* ── Typography ───────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-sm      { font-size: .82rem; }
.text-xs      { font-size: .73rem; }
.font-mono    { font-family: 'JetBrains Mono', monospace; }
code          { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: .82rem; background: var(--surface2); padding: 2px 6px; border-radius: 4px; color: var(--accent); }

/* ── Notifications dropdown ───────────────────────────────── */
.notif-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 320px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); z-index: 300;
}
.notif-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    font-weight: 700; font-size: .845rem;
}
.notif-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    transition: background .15s;
}
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { background: var(--accent-glow); }
.notif-icon {
    width: 34px; height: 34px; border-radius: var(--radius-md);
    display: grid; place-items: center; font-size: .8rem; flex-shrink: 0;
}
.notif-title { font-size: .82rem; font-weight: 600; margin-bottom: 2px; }
.notif-time  { font-size: .7rem; color: var(--text-light); }

/* ── Impersonate bar ──────────────────────────────────────── */
.impersonate-bar {
    background: linear-gradient(90deg, var(--warning), #d97706);
    color: #fff; padding: 8px 24px; font-size: .8rem; font-weight: 600;
    display: flex; align-items: center; gap: 10px;
    position: sticky; top: 0; z-index: 200;
}
.impersonate-bar a { color: #fff; text-decoration: underline; margin-left: auto; }

/* ── Pagination ───────────────────────────────────────────── */
.pagination {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px; border-top: 1px solid var(--border);
    font-size: .8rem; color: var(--text-muted);
}
.pagination-links { display: flex; gap: 4px; }
.page-link {
    padding: 5px 10px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); color: var(--text-muted);
    font-size: .78rem; font-weight: 600; transition: all .15s;
}
.page-link:hover { border-color: var(--accent); color: var(--accent); }
.page-link.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Filter bar ───────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }

/* ── Mobile responsive ────────────────────────────────────── */
@media (max-width: 1024px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
    .app-wrapper { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: -100%; width: 260px;
        transition: left .25s ease; z-index: 200;
    }
    .sidebar.open { left: 0; box-shadow: var(--shadow-xl); }
    .app-main { grid-column: 1; }
    .app-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
    .topbar { padding: 0 16px; }
    .table-wrap { font-size: .78rem; }
    th, td { padding: 8px 10px; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .btn { font-size: .78rem; padding: 7px 14px; }
    .card-body { padding: 14px; }
    .notif-dropdown { width: 290px; right: -60px; }
}
