/* =============================================================
   app.css — theme-agnostic base. Uses only CSS custom properties.
   All colour/font/radius values come from the active theme.json.
   ============================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-alt); }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* ── Layout ── */
.container        { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.container-sm     { max-width: 640px;  margin: 0 auto; padding: 0 1.5rem; }
.page-wrap        { display: flex; flex-direction: column; min-height: 100vh; }
.main-content     { flex: 1; padding: 2rem 0; }

/* App shell (sidebar layout) */
.app-shell        { display: flex; min-height: 100vh; }
.sidebar          { width: 240px; flex-shrink: 0; background: var(--color-sidebar-bg); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; }
.sidebar-logo     { padding: 1.5rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo a   { color: #fff; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: .5rem; }
.sidebar-nav      { flex: 1; padding: 1rem 0; overflow-y: auto; }
.sidebar-nav a    { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; color: var(--color-sidebar-text); font-size: .875rem; font-weight: 500; border-left: 3px solid transparent; transition: background .15s, color .15s, border-color .15s; }
.sidebar-nav a:hover,
.sidebar-nav a.active { background: rgba(255,255,255,.06); color: #fff; border-left-color: var(--color-sidebar-active); }
.sidebar-section  { padding: .5rem 1.25rem .25rem; font-size: .7rem; font-weight: 600; color: rgba(255,255,255,.3); text-transform: uppercase; letter-spacing: .08em; margin-top: .5rem; }
.sidebar-footer   { padding: 1rem 1.25rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .8rem; color: var(--color-sidebar-text); }
.content-with-sidebar { margin-left: 240px; flex: 1; display: flex; flex-direction: column; }

/* Public layout topbar */
.topbar           { background: var(--color-surface); border-bottom: 1px solid var(--color-border); }
.topbar-inner     { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1.5rem; max-width: 1200px; margin: 0 auto; }
.topbar-brand     { font-weight: 700; font-size: 1.1rem; color: var(--color-text); }
.topbar-nav       { display: flex; gap: 1.5rem; align-items: center; }
.topbar-nav a     { font-size: .875rem; font-weight: 500; color: var(--color-text-muted); }
.topbar-nav a:hover { color: var(--color-text); }

/* Page header */
.page-header      { padding: 1.5rem 2rem 0; }
.page-header h1   { font-size: 1.5rem; font-weight: 700; }
.page-header p    { color: var(--color-text-muted); font-size: .9rem; margin-top: .25rem; }

/* ── Cards ── */
.card             { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 1.5rem; box-shadow: var(--shadow-sm); }
.card-header      { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.card-title       { font-size: 1rem; font-weight: 600; }
.card-body        { }
.card + .card     { margin-top: 1rem; }

/* ── Stats grid ── */
.stats-grid       { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 1.5rem 2rem; }
.stat-card        { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: 1.25rem 1.5rem; box-shadow: var(--shadow-sm); }
.stat-label       { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--color-text-muted); }
.stat-value       { font-size: 2rem; font-weight: 700; margin-top: .25rem; color: var(--color-text); }
.stat-sub         { font-size: .8rem; color: var(--color-text-muted); margin-top: .25rem; }

/* ── Grid helpers ── */
.grid-2           { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3           { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4           { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* ── Content padding ── */
.content-pad      { padding: 1.5rem 2rem; }

/* ── Tables ── */
.table-wrap       { overflow-x: auto; }
.data-table       { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th    { text-align: left; padding: .75rem 1rem; font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--color-text-muted); border-bottom: 1px solid var(--color-border); background: var(--color-surface-alt); }
.data-table td    { padding: .75rem 1rem; border-bottom: 1px solid var(--color-border); color: var(--color-text); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--color-surface-alt); }
.data-table .mono { font-family: var(--font-mono); font-size: .8rem; }

/* ── Forms ── */
.form-group       { margin-bottom: 1.25rem; }
.form-label       { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .4rem; color: var(--color-text); }
.form-hint        { font-size: .8rem; color: var(--color-text-muted); margin-top: .25rem; }
.input            { display: block; width: 100%; padding: .625rem .875rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); color: var(--color-text); font-family: var(--font-sans); font-size: .9rem; transition: border-color .15s, box-shadow .15s; }
.input:focus      { outline: none; border-color: var(--color-border-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 15%, transparent); }
textarea.input    { resize: vertical; min-height: 100px; }
select.input      { cursor: pointer; }

/* ── Buttons ── */
.btn              { display: inline-flex; align-items: center; gap: .4rem; padding: .6rem 1.2rem; border: none; border-radius: var(--radius-md); font-family: var(--font-sans); font-size: .875rem; font-weight: 600; cursor: pointer; transition: background .15s, opacity .15s, transform .1s; text-decoration: none; white-space: nowrap; }
.btn:active       { transform: translateY(1px); }
.btn-primary      { background: var(--color-primary); color: #fff; }
.btn-primary:hover{ background: var(--color-primary-alt); color: #fff; }
.btn-accent       { background: var(--color-accent); color: #fff; }
.btn-accent:hover { background: var(--color-accent-alt); color: #fff; }
.btn-danger       { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: var(--color-danger-alt); color: #fff; }
.btn-ghost        { background: transparent; color: var(--color-text-muted); border: 1px solid var(--color-border); }
.btn-ghost:hover  { background: var(--color-surface-alt); color: var(--color-text); }
.btn-sm           { padding: .35rem .75rem; font-size: .8rem; }
.btn-full         { width: 100%; justify-content: center; }

/* ── Badges ── */
.badge            { display: inline-flex; align-items: center; padding: .2rem .6rem; border-radius: 999px; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.badge-primary    { background: color-mix(in srgb, var(--color-primary) 15%, transparent); color: var(--color-primary); }
.badge-accent     { background: color-mix(in srgb, var(--color-accent) 15%, transparent); color: var(--color-accent-alt); }
.badge-danger     { background: color-mix(in srgb, var(--color-danger) 15%, transparent); color: var(--color-danger); }
.badge-warning    { background: color-mix(in srgb, var(--color-warning) 15%, transparent); color: var(--color-warning); }
.badge-muted      { background: var(--color-surface-alt); color: var(--color-text-muted); }
.badge-admin      { background: color-mix(in srgb, var(--color-primary) 15%, transparent); color: var(--color-primary); }
.badge-verified   { background: color-mix(in srgb, var(--color-accent) 15%, transparent); color: var(--color-accent-alt); }

/* ── Alerts ── */
.alert            { padding: .875rem 1.125rem; border-radius: var(--radius-md); border-left: 4px solid; font-size: .875rem; margin-bottom: 1rem; }
.alert-success    { background: color-mix(in srgb, var(--color-accent) 10%, transparent); border-color: var(--color-accent); color: var(--color-accent-alt); }
.alert-danger     { background: color-mix(in srgb, var(--color-danger) 10%, transparent); border-color: var(--color-danger); color: var(--color-danger); }
.alert-info       { background: color-mix(in srgb, var(--color-primary) 10%, transparent); border-color: var(--color-primary); color: var(--color-primary); }
.alert-warning    { background: color-mix(in srgb, var(--color-warning) 10%, transparent); border-color: var(--color-warning); color: var(--color-warning); }

/* ── Avatar / profile ── */
.avatar           { width: 40px; height: 40px; border-radius: 50%; background: var(--color-primary); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: .9rem; flex-shrink: 0; }
.avatar-lg        { width: 64px; height: 64px; font-size: 1.4rem; }
.profile-card     { display: flex; align-items: flex-start; gap: 1.25rem; }
.profile-info h2  { font-size: 1.25rem; font-weight: 700; }
.profile-info p   { color: var(--color-text-muted); font-size: .875rem; }
.profile-meta     { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }

/* ── Utility ── */
.text-muted       { color: var(--color-text-muted); }
.text-sm          { font-size: .875rem; }
.text-xs          { font-size: .75rem; }
.text-mono        { font-family: var(--font-mono); }
.text-right       { text-align: right; }
.text-center      { text-align: center; }
.fw-600           { font-weight: 600; }
.fw-700           { font-weight: 700; }
.d-flex           { display: flex; }
.align-center     { align-items: center; }
.justify-between  { justify-content: space-between; }
.gap-1            { gap: .5rem; }
.gap-2            { gap: 1rem; }
.mt-1             { margin-top: .5rem; }
.mt-2             { margin-top: 1rem; }
.mt-3             { margin-top: 1.5rem; }
.mb-1             { margin-bottom: .5rem; }
.mb-2             { margin-bottom: 1rem; }
.mb-3             { margin-bottom: 1.5rem; }
.p-0              { padding: 0; }
.w-full           { width: 100%; }
.divider          { border: none; border-top: 1px solid var(--color-border); margin: 1.5rem 0; }
.empty-state      { text-align: center; padding: 3rem 1rem; color: var(--color-text-muted); }
.empty-state h3   { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; color: var(--color-text); }

/* ── Auth pages (minimal layout) ── */
.auth-wrap        { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; background: var(--color-bg); }
.auth-box         { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xl); padding: 2.5rem; width: 100%; max-width: 420px; box-shadow: var(--shadow-md); }
.auth-logo        { text-align: center; margin-bottom: 2rem; }
.auth-logo span   { font-size: 1.5rem; font-weight: 700; color: var(--color-text); }
.auth-title       { font-size: 1.25rem; font-weight: 700; margin-bottom: .25rem; }
.auth-sub         { color: var(--color-text-muted); font-size: .875rem; margin-bottom: 1.75rem; }
.auth-footer      { text-align: center; margin-top: 1.5rem; font-size: .875rem; color: var(--color-text-muted); }

/* ── Footer ── */
.footer           { padding: 1.5rem; text-align: center; font-size: .8rem; color: var(--color-text-muted); border-top: 1px solid var(--color-border); background: var(--color-surface); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar      { transform: translateX(-100%); }
    .content-with-sidebar { margin-left: 0; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .stats-grid   { grid-template-columns: 1fr 1fr; }
    .page-header, .stats-grid, .content-pad { padding-left: 1rem; padding-right: 1rem; }
}
