/* ---------- Tokens ---------- */
:root {
    color-scheme: light dark;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f1f3f6;
    --border: #e3e6eb;
    --border-strong: #cfd4dc;
    --text: #151a23;
    --text-2: #4d5665;
    --text-3: #6f7889;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-soft: #eef0ff;
    --accent-text: #ffffff;
    --danger: #c81e1e;
    --danger-soft: #fdecec;
    --ok: #15803d;
    --ok-soft: #e7f6ec;
    --info: #1d4ed8;
    --info-soft: #e8efff;
    --warn: #a14a06;
    --warn-soft: #fdf3e2;
    --neutral-soft: #eef0f3;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --radius: 12px;
    --radius-sm: 8px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1117;
        --surface: #151b24;
        --surface-2: #1c2430;
        --border: #262f3c;
        --border-strong: #354152;
        --text: #e8ecf2;
        --text-2: #b0b9c6;
        --text-3: #8a95a5;
        --accent: #818cf8;
        --accent-hover: #a5b4fc;
        --accent-soft: #23264a;
        --accent-text: #0d1117;
        --danger: #f87171;
        --danger-soft: #3a1c1f;
        --ok: #4ade80;
        --ok-soft: #16301f;
        --info: #93b4ff;
        --info-soft: #1a2747;
        --warn: #fbbf24;
        --warn-soft: #362a12;
        --neutral-soft: #222a36;
        --shadow: none;
    }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 650; }
p { margin: 0; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { width: 1em; height: 1em; flex: none; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */
.page { min-height: 100vh; display: flex; flex-direction: column; }
.container { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 20px; }
main.container { flex: 1; padding-top: 32px; padding-bottom: 64px; }

.topbar {
    position: sticky; top: 0; z-index: 10;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 16px; height: 60px; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand-mark { display: block; width: 30px; height: 30px; }

.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav-link {
    color: var(--text-2); padding: 6px 10px; border-radius: var(--radius-sm); font-size: .93rem; font-weight: 500;
}
.nav-link:hover, .nav-link.active { background: var(--surface-2); color: var(--text); text-decoration: none; }

.footer { border-top: 1px solid var(--border); color: var(--text-3); font-size: .85rem; }
.footer .container { padding-top: 20px; padding-bottom: 28px; display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
.footer a { color: var(--text-2); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { color: var(--text-2); margin-top: 6px; }

.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: .9rem; margin-bottom: 16px; }
.back-link:hover { color: var(--text); text-decoration: none; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
    font-weight: 550; font-size: .92rem; cursor: pointer; white-space: nowrap;
    transition: background-color .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ok { color: var(--ok); }
.btn-ok:hover { background: var(--ok-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: .85rem; }

/* ---------- Forms ---------- */
.input, .select, .textarea {
    width: 100%; height: 38px; padding: 0 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
    font: inherit; font-size: .93rem;
}
.textarea { height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; }
.select {
    padding-right: 32px; appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8495' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.field { display: grid; gap: 6px; margin-bottom: 22px; }
.field-label { font-weight: 600; font-size: .93rem; }
.field-help { color: var(--text-3); font-size: .85rem; }
.field-count { color: var(--text-3); font-size: .8rem; text-align: right; }

.input-search { position: relative; }
.input-search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.input-search .input { padding-left: 34px; }

.validation-message { color: var(--danger); font-size: .85rem; }
.validation-errors { color: var(--danger); font-size: .88rem; padding: 10px 14px 10px 30px; margin: 0 0 18px; background: var(--danger-soft); border-radius: var(--radius-sm); }
.input.invalid, .textarea.invalid { border-color: var(--danger); }

.choice-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice-body {
    display: block; height: 100%; padding: 12px 14px; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); background: var(--surface);
}
.choice-body strong { display: block; font-size: .93rem; }
.choice-body span { color: var(--text-3); font-size: .85rem; }
.choice input:checked + .choice-body { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.choice input:focus-visible + .choice-body { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 24px; }
.stack > * + * { margin-top: 16px; }
.narrow { max-width: 720px; margin: 0 auto; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .input-search { flex: 1 1 220px; }
.toolbar .select { width: auto; min-width: 150px; flex: 0 1 190px; }

.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 10px; border: 1px solid var(--border); }
.segmented button {
    border: 0; background: transparent; padding: 0 14px; height: 30px; border-radius: 7px;
    font-weight: 550; font-size: .9rem; color: var(--text-2); cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.result-count { color: var(--text-3); font-size: .88rem; margin-bottom: 10px; }

/* ---------- Suggestion list ---------- */
.list { display: grid; gap: 10px; }

.item {
    display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: start;
    padding: 16px 18px; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); transition: border-color .12s;
}
.item:hover { border-color: var(--border-strong); }
.item-body { min-width: 0; }
.item-title { font-weight: 650; font-size: 1.02rem; color: var(--text); }
.item-title:hover { color: var(--accent); text-decoration: none; }
.item-desc {
    color: var(--text-2); margin-top: 4px; font-size: .93rem;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; color: var(--text-3); font-size: .84rem; }
.meta-actions { margin-left: auto; display: flex; gap: 6px; }

.vote {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 56px; height: 62px; border-radius: 10px; border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text-2); cursor: pointer; transition: all .12s;
}
.vote .icon { width: 18px; height: 18px; }
.vote-count { font-weight: 700; font-size: 1rem; color: var(--text); font-variant-numeric: tabular-nums; }
.vote:hover { border-color: var(--accent); color: var(--accent); }
.vote.is-voted { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.vote.is-voted .vote-count { color: var(--accent-text); }
.vote.is-own { cursor: default; background: var(--surface-2); border-style: dashed; }
.vote.is-own:hover { border-color: var(--border-strong); color: var(--text-2); }
.vote-lg { width: 68px; height: 76px; }
.vote-lg .vote-count { font-size: 1.2rem; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
    border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap;
    background: var(--neutral-soft); color: var(--text-2);
}
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-completado { background: var(--ok-soft); color: var(--ok); }
.badge-en-revision { background: var(--info-soft); color: var(--info); }
.badge-proximamente { background: var(--warn-soft); color: var(--warn); }
.badge-rechazada { background: var(--danger-soft); color: var(--danger); }
.badge-pendiente { background: var(--warn-soft); color: var(--warn); }

/* ---------- Detail ---------- */
.detail { display: grid; grid-template-columns: auto 1fr; gap: 20px; }
.detail h1 { font-size: 1.5rem; }
.detail-desc { color: var(--text-2); margin-top: 12px; white-space: pre-line; }

.status-panel { display: grid; gap: 8px; padding: 18px 20px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); }
.status-panel p { color: var(--text-2); }

.panel-title { margin-bottom: 4px; }
.panel-help { color: var(--text-3); font-size: .88rem; margin-bottom: 14px; }
.status-options { display: flex; flex-wrap: wrap; gap: 8px; }
.status-options button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.section-title { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-bottom: 6px; }

/* ---------- Profile / admin rows ---------- */
.row-item { display: grid; gap: 4px; padding: 14px 0; border-top: 1px solid var(--border); }
.row-item:first-of-type { border-top: 0; }
.row-item .meta { margin-top: 2px; }
.row-title { font-weight: 600; color: var(--text); }
.row-note { color: var(--text-2); font-size: .9rem; }

.admin-item { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: start; }
.admin-actions { display: flex; gap: 8px; }
.inline-edit { display: flex; gap: 6px; align-items: center; margin: 2px 0; }
.inline-edit .input { flex: 1; }
.edit-btn { border: 0; background: none; padding: 2px 4px; color: var(--text-3); cursor: pointer; border-radius: 4px; vertical-align: -2px; }
.edit-btn:hover { color: var(--accent); }

/* ---------- Empty, skeleton ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty h2 { color: var(--text); margin-bottom: 6px; }

.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 6px; }
.skeleton::after {
    content: ""; position: absolute; inset: 0; transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent);
    animation: shimmer 1.3s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } }
.sk-vote { width: 56px; height: 62px; border-radius: 10px; }
.sk-line { height: 14px; margin-top: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    main.container { padding-top: 20px; }
    h1 { font-size: 1.35rem; }
    .card-pad { padding: 18px; }
    .item { padding: 14px; gap: 12px; }
    .vote { width: 48px; height: 56px; }
    .sk-vote { width: 48px; height: 56px; }
    .toolbar .select { flex: 1 1 140px; }
    .segmented { width: 100%; }
    .segmented button { flex: 1; }
    .detail { grid-template-columns: 1fr; }
    .detail .vote-lg { flex-direction: row; gap: 8px; width: auto; height: 40px; padding: 0 14px; justify-self: start; }
    .admin-item { grid-template-columns: 1fr; }
    .nav-link { padding: 6px 8px; }
    .brand-name { display: none; }
}

/* ---------- Blazor ---------- */
#blazor-error-ui {
    background: var(--warn-soft); color: var(--text); bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    display: none; left: 0; padding: .7rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .6rem; }

.blazor-error-boundary { background: var(--danger-soft); color: var(--danger); padding: 1rem; border-radius: var(--radius-sm); }
.blazor-error-boundary::after { content: "Ocurrió un error."; }

h1:focus { outline: none; }
