/*
 * Shared design system for the internal console (admin.php, dashboard.php)
 * and the auth screens (login.php, admin-login.php, reset-*.php).
 * Dark "ops console" theme. review.php is out of scope — it has its own
 * per-business branding system and should not use this file.
 */

:root {
    --bg:            #0b1220;
    --surface:       #141d2e;
    --surface-alt:   #0f1727;
    --surface-hover: #1a2540;
    --border:        rgba(255,255,255,0.08);
    --border-strong: rgba(255,255,255,0.16);
    --text-main:     #e5eaf2;
    --text-muted:    #8b95a8;
    --text-faint:    #5b6478;

    --accent:        #22d3ee;
    --accent-dim:    rgba(34,211,238,0.12);
    --accent-text:   #0b1220;

    --green:         #34d399;
    --green-dim:     rgba(52,211,153,0.14);
    --red:           #f87171;
    --red-dim:       rgba(248,113,113,0.14);
    --amber:         #fbbf24;
    --amber-dim:     rgba(251,191,36,0.14);
    --purple:        #c084fc;
    --purple-dim:    rgba(192,132,252,0.14);

    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 8px 24px rgba(0,0,0,0.35);
    --font-ui: system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--text-main); font-weight: 600; margin: 0 0 0.75rem; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: 0.9rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
p { color: var(--text-muted); line-height: 1.5; }
a { color: var(--accent); }
code { font-family: var(--font-mono); }

/* ── App shell: sidebar + main content ─────────────────────────────── */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--surface-alt);
    border-right: 1px solid var(--border);
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.95rem;
    padding: 0 0.5rem 1.25rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.sidebar nav a {
    display: block;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    margin-bottom: 0.15rem;
    transition: background 0.12s, color 0.12s;
}
.sidebar nav a:hover { background: var(--surface-hover); color: var(--text-main); }
.sidebar .logout {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.sidebar .logout a { color: var(--red); }

.main {
    flex: 1;
    min-width: 0;
    padding: 2rem 2.5rem 4rem;
    max-width: 1400px;
}

.topbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 0.25rem;
}
.topbar p { margin-bottom: 2rem; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    scroll-margin-top: 1.5rem;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-accent { border-left: 3px solid var(--accent); }
.card-accent.purple { border-left-color: var(--purple); }

/* ── Forms ──────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-bottom: 1.5rem; }
.form-group { margin-bottom: 1rem; }
label { display: block; font-weight: 500; margin-bottom: 0.4rem; font-size: 0.85rem; color: var(--text-muted); }

input[type="text"], input[type="url"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], select, textarea {
    width: 100%;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-alt);
    color: var(--text-main);
    font-family: var(--font-ui);
    font-size: 0.9rem;
}
textarea { font-family: var(--font-mono); }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}
input[type="color"] { height: 38px; width: 100%; padding: 0; border: none; border-radius: var(--radius-sm); background: none; }
input::placeholder { color: var(--text-faint); }

.toggle-group {
    background: var(--surface-alt);
    padding: 0.9rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 0.75rem;
}
.toggle-group label { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; color: var(--text-main); margin-bottom: 0; }
.toggle-group .hint { margin: 0.35rem 0 0 1.6rem; font-size: 0.75rem; color: var(--text-faint); }

button, .btn {
    display: inline-block;
    background: var(--accent);
    color: var(--accent-text);
    border: none;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.88rem;
    text-decoration: none;
    text-align: center;
    transition: filter 0.12s;
}
button:hover, .btn:hover { filter: brightness(1.1); }
form > button:only-child, form.full-width button { width: 100%; }

.btn-ghost { background: transparent; border: 1px solid var(--border-strong); color: var(--text-main); }
.btn-danger { background: var(--red); color: #250807; }
.btn-success { background: var(--green); color: #052e1f; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.78rem; }

/* ── Tables ─────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
th, td { text-align: left; padding: 0.85rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-faint); font-weight: 600; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

/* ── Badges & feature-toggle pills ─────────────────────────────────── */
.badge { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px; font-size: 0.7rem; font-weight: 700; margin: 0 0.2rem 0.2rem 0; letter-spacing: 0.02em; }
.badge.on     { background: var(--green-dim);  color: var(--green); }
.badge.off    { background: var(--red-dim);    color: var(--red); }
.badge.plan   { background: var(--accent-dim); color: var(--accent); }
.badge.agency { background: var(--amber-dim);  color: var(--amber); }
.badge.neutral{ background: rgba(255,255,255,0.06); color: var(--text-muted); }

.feat-btn { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.6rem; border-radius: 999px; font-size: 0.72rem; font-weight: 700; text-decoration: none; margin: 0.15rem; border: none; cursor: pointer; }
.feat-on  { background: var(--green-dim); color: var(--green); }
.feat-off { background: rgba(255,255,255,0.05); color: var(--text-faint); }
.feat-on:hover  { background: rgba(52,211,153,0.22); }
.feat-off:hover { background: rgba(255,255,255,0.1); }

.action-btn { font-size: 0.78rem; padding: 0.3rem 0.7rem; border-radius: var(--radius-sm); text-decoration: none; color: #fff; display: inline-block; }
.action-btn.suspend { background: var(--red); }
.action-btn.activate { background: var(--green); color: #052e1f; }

.link-field, .link { font-family: var(--font-mono); background: var(--surface-alt); padding: 0.3rem 0.6rem; border-radius: var(--radius-sm); font-size: 0.8rem; color: var(--text-muted); border: 1px solid var(--border); }

/* ── Alerts ─────────────────────────────────────────────────────────── */
.alert { padding: 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; border: 1px solid transparent; font-size: 0.88rem; }
.alert-success { background: var(--green-dim); color: var(--green); border-color: rgba(52,211,153,0.3); }
.alert-warning { background: var(--amber-dim); color: var(--amber); border-color: rgba(251,191,36,0.3); }
.alert-error   { background: var(--red-dim);   color: var(--red);   border-color: rgba(248,113,113,0.3); }
.alert strong { color: inherit; }

/* ── Stat tiles ─────────────────────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.stat-tile .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-faint); margin-bottom: 0.35rem; }
.stat-tile .value { font-size: 1.5rem; font-weight: 700; color: var(--text-main); }
.stat-tile .value.accent { color: var(--accent); }

/* ── Auth screens (login.php, admin-login.php, reset-*.php) ──────────── */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}
.auth-card .brand {
    text-align: center;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.35rem;
}
.auth-card h1 { text-align: center; font-size: 1.15rem; margin-bottom: 0.35rem; }
.auth-card .subtitle { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1.5rem; }
.auth-card .foot-link { text-align: center; margin-top: 1.25rem; font-size: 0.82rem; color: var(--text-muted); }
.auth-card .foot-link a { color: var(--accent); text-decoration: none; }
.auth-card .foot-link a:hover { text-decoration: underline; }

/* ── Utility ────────────────────────────────────────────────────────── */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mt-3 { margin-top: 3rem; }
.overflow-x { overflow-x: auto; }
details { font-size: 0.8rem; }
details summary { cursor: pointer; font-weight: 600; color: var(--accent); outline: none; }
details > div { margin-top: 0.5rem; color: var(--text-muted); line-height: 1.6; }

@media (max-width: 900px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .main { padding: 1.25rem; }
    .form-grid { grid-template-columns: 1fr; }
}
