/* Vanilla replica of the Next.js app's shadcn "new-york" theme (app/globals.css). */

:root {
    --background: oklch(1 0 0);
    --foreground: oklch(0.145 0 0);
    --card: oklch(1 0 0);
    --card-foreground: oklch(0.145 0 0);
    --primary: oklch(0.488 0.243 264.376);
    --primary-foreground: oklch(0.97 0.014 254.604);
    --secondary: oklch(0.967 0.001 286.375);
    --secondary-foreground: oklch(0.21 0.006 285.885);
    --muted: oklch(0.97 0 0);
    --muted-foreground: oklch(0.556 0 0);
    --accent: oklch(0.97 0 0);
    --accent-foreground: oklch(0.205 0 0);
    --destructive: oklch(0.577 0.245 27.325);
    --destructive-foreground: oklch(0.985 0 0);
    --border: oklch(0.922 0 0);
    --input: oklch(0.922 0 0);
    --ring: oklch(0.708 0 0);
    --radius: 0.625rem;
    --radius-md: calc(var(--radius) * 0.8);
    --radius-lg: var(--radius);
    --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

html.dark {
    --background: oklch(0.145 0 0);
    --foreground: oklch(0.985 0 0);
    --card: oklch(0.205 0 0);
    --card-foreground: oklch(0.985 0 0);
    --primary: oklch(0.424 0.199 265.638);
    --primary-foreground: oklch(0.97 0.014 254.604);
    --secondary: oklch(0.274 0.006 286.033);
    --secondary-foreground: oklch(0.985 0 0);
    --muted: oklch(0.269 0 0);
    --muted-foreground: oklch(0.708 0 0);
    --accent: oklch(0.269 0 0);
    --accent-foreground: oklch(0.985 0 0);
    --destructive: oklch(0.704 0.191 22.216);
    --border: oklch(1 0 0 / 10%);
    --input: oklch(1 0 0 / 15%);
    --ring: oklch(0.556 0 0);
}

*, *::before, *::after {
    box-sizing: border-box;
    border-color: var(--border);
}

body {
    margin: 0;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }

/* ---------- Layout ---------- */

.page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 64rem;
    min-height: 100svh;
    margin: 0 auto;
    padding: 1.5rem;
}

.page-centered {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100svh;
    padding: 1.5rem;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

.stack { display: flex; flex-direction: column; gap: 1rem; }

/* ---------- Card ---------- */

.card {
    background: var(--card);
    color: var(--card-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    padding: 1.5rem;
}

.card-title { font-size: 1rem; font-weight: 600; }
.card-description { font-size: 0.875rem; color: var(--muted-foreground); margin-top: 0.375rem; }

/* ---------- KPI card ---------- */

.kpi { display: flex; align-items: center; gap: 1rem; }

.kpi-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
    border-radius: 0.5rem;
    background: var(--muted);
    color: var(--muted-foreground);
}

.kpi-icon .icon { width: 1.25rem; height: 1.25rem; }

.kpi-value { display: block; font-size: 1.5rem; font-weight: 700; line-height: 2rem; }

.kpi-label {
    display: block;
    font-size: 0.75rem;
    letter-spacing: 0.025em;
    text-transform: uppercase;
    color: var(--muted-foreground);
}

/* ---------- Question card ---------- */

.question-card { display: flex; flex-direction: column; gap: 1.25rem; }

.question-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.question-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    background: var(--muted);
    color: var(--muted-foreground);
    font-size: 0.75rem;
    font-weight: 500;
}

.question-head h2 { font-size: 1rem; font-weight: 500; }
.question-responses { font-size: 0.875rem; color: var(--muted-foreground); }

.option-list { display: flex; flex-direction: column; gap: 1rem; }
.option { display: flex; flex-direction: column; gap: 0.375rem; }

.option-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.option-label { font-size: 0.875rem; }
.option-value { font-size: 0.875rem; font-weight: 600; white-space: nowrap; }
.option-count { font-weight: 400; color: var(--muted-foreground); }

.bar-track {
    height: 0.5rem;
    width: 100%;
    overflow: hidden;
    border-radius: 9999px;
    background: var(--muted);
}

.bar-fill { height: 100%; border-radius: 9999px; }

/* ---------- Badge ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1rem;
    white-space: nowrap;
}

.badge-default { background: var(--primary); color: var(--primary-foreground); }
.badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge-destructive { background: var(--destructive); color: #fff; }
.badge-outline { border-color: var(--border); color: var(--foreground); background: transparent; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 120ms ease, opacity 120ms ease;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn .icon { width: 1rem; height: 1rem; }

@keyframes icon-spin { to { transform: rotate(360deg); } }
.icon-spin { animation: icon-spin 0.6s linear infinite; }

.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover:not(:disabled) { opacity: 0.9; }

.btn-outline {
    background: var(--background);
    border-color: var(--border);
    color: var(--foreground);
}
.btn-outline:hover:not(:disabled) { background: var(--accent); color: var(--accent-foreground); }

.btn-destructive { background: var(--destructive); color: #fff; }
.btn-destructive:hover:not(:disabled) { opacity: 0.9; }

.btn-sm { padding: 0.25rem 0.625rem; font-size: 0.8125rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 0.5rem; }

.label { font-size: 0.875rem; font-weight: 500; line-height: 1; }

.input, .select {
    width: 100%;
    height: 2.25rem;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--input);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--foreground);
    font-family: inherit;
    font-size: 0.875rem;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

html.dark .input, html.dark .select { background: oklch(1 0 0 / 5%); }

.input::placeholder { color: var(--muted-foreground); }

.input:focus-visible, .select:focus-visible {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent);
}

.form-error { font-size: 0.875rem; color: var(--destructive); }
.form-success { font-size: 0.875rem; color: #16a34a; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .form-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Submissions table ---------- */

.table-head-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.table-head-row .title-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.table-head-row h2 { font-size: 1rem; font-weight: 500; }

.search-wrap { position: relative; width: 100%; }

@media (min-width: 640px) {
    .search-wrap { width: 18rem; }
}

.search-wrap .icon {
    position: absolute;
    top: 50%;
    left: 0.625rem;
    width: 1rem;
    height: 1rem;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--muted-foreground);
}

.search-wrap .input { padding-left: 2rem; }

.table-scroll {
    max-height: 32rem;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.data-table {
    width: 100%;
    min-width: 56rem;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in oklab, var(--muted) 80%, transparent);
    backdrop-filter: blur(4px);
}

.data-table th {
    padding: 0.625rem 0.75rem;
    font-weight: 500;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: color-mix(in oklab, var(--muted) 40%, transparent); }

.cell-muted { color: var(--muted-foreground); white-space: nowrap; }
.cell-medium { font-weight: 500; }
.cell-nowrap { white-space: nowrap; }

.empty-row td {
    padding: 2rem 0.75rem;
    text-align: center;
    color: var(--muted-foreground);
}

/* ---------- Login ---------- */

.login-card { width: 100%; max-width: 24rem; }
.login-card form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.5rem; }

/* ---------- Updater extras ---------- */

.nav-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .nav-cards { grid-template-columns: repeat(2, 1fr); }
}

.nav-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    transition: background-color 120ms ease;
}

.nav-card:hover { background: var(--accent); }

.row-actions { display: flex; gap: 0.375rem; white-space: nowrap; }
.inline-form { display: inline; }

.option-editor { display: flex; flex-direction: column; gap: 0.5rem; }

.option-editor-row {
    display: grid;
    grid-template-columns: 1fr 6rem 6rem 2.25rem;
    gap: 0.5rem;
    align-items: center;
}

.muted-note { font-size: 0.8125rem; color: var(--muted-foreground); }

.log-pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.8125rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 32rem;
    overflow-y: auto;
    background: var(--accent);
    border-radius: 0.5rem;
    padding: 1rem;
}

.section-title { font-size: 1rem; font-weight: 600; margin-top: 0.5rem; }

.flash {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    background: var(--muted);
}
