/* =====================================================================
   MatchPlayApp · Design system
   1. Tokens (claro / oscuro)      5. Formularios
   2. Base                         6. Componentes (cards, chips, modal, toast…)
   3. Layout (shell, nav)          7. Estados y utilidades
   4. Botones
   Los estilos propios de una pantalla van en su archivo .razor.css.
   ===================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
    --blue-50: #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-300: #93c5fd;
    --blue-400: #60a5fa;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-800: #1e40af;
    --blue-900: #1e3a8a;

    --color-primary: var(--blue-600);
    --color-primary-hover: var(--blue-700);
    --color-primary-soft: var(--blue-50);
    --color-primary-soft-strong: var(--blue-100);
    --color-on-primary: #ffffff;

    --color-bg: #f5f8ff;
    --color-surface: #ffffff;
    --color-surface-2: #f1f5fb;
    --color-border: #dfe6f1;
    --color-border-strong: #c5d0e2;
    --color-text: #0f1b33;
    --color-text-muted: #5b6b86;
    --color-text-subtle: #8593ab;

    --color-success: #15803d;
    --color-success-soft: #e8f7ee;
    --color-warning: #b45309;
    --color-warning-soft: #fdf3e3;
    --color-danger: #c62828;
    --color-danger-soft: #fdeceb;
    --color-like: var(--blue-600);
    --color-nope: #64748b;

    --gradient-brand: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 55%, #1e3a8a 100%);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 999px;

    --shadow-sm: 0 1px 2px rgb(15 27 51 / 6%);
    --shadow: 0 4px 16px rgb(15 27 51 / 8%);
    --shadow-lg: 0 18px 40px rgb(15 27 51 / 16%);
    --focus-ring: 0 0 0 3px rgb(37 99 235 / 35%);

    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --sidebar-width: 248px;
    --sidebar-compact-width: 76px;
    --topbar-height: 56px;
    --bottom-nav-height: 64px;
    --content-max: 1080px;

    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --color-primary: var(--blue-500);
        --color-primary-hover: var(--blue-400);
        --color-primary-soft: rgb(59 130 246 / 14%);
        --color-primary-soft-strong: rgb(59 130 246 / 24%);
        --color-bg: #0b1220;
        --color-surface: #111a2e;
        --color-surface-2: #17223a;
        --color-border: #24314d;
        --color-border-strong: #33446a;
        --color-text: #e6ecf7;
        --color-text-muted: #9aa8c0;
        --color-text-subtle: #6f7f9c;
        --color-success: #4ade80;
        --color-success-soft: rgb(74 222 128 / 12%);
        --color-warning: #fbbf24;
        --color-warning-soft: rgb(251 191 36 / 12%);
        --color-danger: #f87171;
        --color-danger-soft: rgb(248 113 113 / 12%);
        --color-nope: #94a3b8;
        --shadow: 0 4px 16px rgb(0 0 0 / 35%);
        --shadow-lg: 0 18px 40px rgb(0 0 0 / 50%);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --color-primary: var(--blue-500);
    --color-primary-hover: var(--blue-400);
    --color-primary-soft: rgb(59 130 246 / 14%);
    --color-primary-soft-strong: rgb(59 130 246 / 24%);
    --color-bg: #0b1220;
    --color-surface: #111a2e;
    --color-surface-2: #17223a;
    --color-border: #24314d;
    --color-border-strong: #33446a;
    --color-text: #e6ecf7;
    --color-text-muted: #9aa8c0;
    --color-text-subtle: #6f7f9c;
    --color-success: #4ade80;
    --color-success-soft: rgb(74 222 128 / 12%);
    --color-warning: #fbbf24;
    --color-warning-soft: rgb(251 191 36 / 12%);
    --color-danger: #f87171;
    --color-danger-soft: rgb(248 113 113 / 12%);
    --color-nope: #94a3b8;
    --shadow: 0 4px 16px rgb(0 0 0 / 35%);
    --shadow-lg: 0 18px 40px rgb(0 0 0 / 50%);
    color-scheme: dark;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

html, body { margin: 0; min-height: 100%; }

body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.5;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
hr { border: 0; border-top: 1px solid var(--color-border); margin: 1.25rem 0; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
main:focus { outline: none; }
/* Blazor enfoca el h1 al navegar (lectores de pantalla): sin anillo visible porque no es foco del usuario. */
h1:focus, [tabindex="-1"]:focus { outline: none; box-shadow: none; }

.skip-link {
    position: absolute; left: 1rem; top: -100px; z-index: 100;
    background: var(--color-primary); color: var(--color-on-primary);
    padding: .5rem 1rem; border-radius: var(--radius);
}
.skip-link:focus { top: 1rem; }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 3. Layout ---------- */
.brand {
    display: inline-flex; align-items: center; gap: .6rem;
    font-weight: 800; font-size: 1.15rem; color: var(--color-text); letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-light { color: #fff; }
.brand-mark { flex-shrink: 0; }

/* Leyenda Beta junto al logo */
.brand-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; min-width: 0; }
.topbar .brand-row, .public-topbar .brand-row { flex-wrap: nowrap; }
.topbar .beta-badge { padding: .1rem .45rem; font-size: .65rem; }
@media (max-width: 419px) {
    /* No entra todo: queda el logo con el badge */
    .topbar .brand-row:has(.beta-badge) .brand span { display: none; }
}
.beta-badge {
    display: inline-flex; align-items: center; min-height: 24px; padding: .1rem .55rem;
    border-radius: 999px; background: var(--color-primary-soft); color: var(--color-primary);
    font-size: .72rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap;
}
a.beta-badge { position: relative; }
a.beta-badge::after { content: ""; position: absolute; inset: -10px -4px; } /* objetivo táctil de 44 px */
a.beta-badge:hover { text-decoration: none; filter: brightness(.95); }
.beta-welcome { display: flex; flex-direction: column; align-items: flex-start; gap: .75rem; }
.beta-welcome p { margin: 0; }

/* App de Play Store: actualización obligatoria (bloquea) o disponible (aviso) */
.update-gate {
    position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 1.5rem;
    background: var(--color-bg);
}
.update-gate-card { max-width: 360px; width: 100%; align-items: center; text-align: center; }
.update-gate-card h1 { margin: 0; font-size: 1.5rem; }
.update-banner {
    position: fixed; left: 1rem; right: 1rem; bottom: calc(var(--bottom-nav-height, 64px) + 1rem + env(safe-area-inset-bottom));
    z-index: 900; display: flex; align-items: center; gap: .75rem; padding: .6rem .6rem .6rem 1rem;
    border-radius: var(--radius); background: var(--color-surface); box-shadow: var(--shadow-lg, 0 8px 24px rgb(0 0 0 / .15));
    border: 1px solid var(--color-border);
}
.update-banner span { flex: 1; font-size: .9rem; }
/* Selector de emojis del chat */
.emoji-picker { position: static; display: contents; }
.emoji-backdrop { position: fixed; inset: 0; z-index: 30; }
.emoji-panel {
    position: absolute; left: .5rem; right: .5rem; bottom: calc(100% + .5rem); z-index: 31;
    max-width: 360px; display: flex; flex-direction: column; gap: .5rem; padding: .75rem;
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}
.emoji-search { width: 100%; }
.emoji-tabs { display: flex; gap: .15rem; overflow-x: auto; }
.emoji-tab {
    flex: 0 0 auto; min-width: 36px; min-height: 36px; border: 0; border-radius: 8px; background: none;
    font-size: 1.2rem; cursor: pointer; opacity: .6;
}
.emoji-tab.active { background: var(--color-primary-soft); opacity: 1; }
.emoji-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: .15rem;
    max-height: 220px; overflow-y: auto;
}
.emoji-option {
    min-height: 44px; border: 0; border-radius: 8px; background: none; font-size: 1.5rem; cursor: pointer;
}
.emoji-option:hover, .emoji-option:focus-visible { background: var(--color-surface-2); }
.emoji-empty { grid-column: 1 / -1; margin: .5rem 0; }

.delete-steps { margin: 0; padding-left: 1.25rem; display: flex; flex-direction: column; gap: .35rem; }

.app-shell { min-height: 100dvh; }

/* Celular: barra superior + navegación inferior */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    height: calc(var(--topbar-height) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 1rem 0;
    background: color-mix(in srgb, var(--color-surface) 88%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--color-border);
}
.topbar-actions { display: flex; gap: .25rem; }

.sidebar { display: none; }

.content {
    width: 100%; max-width: var(--content-max); margin: 0 auto;
    padding: 1rem 1rem calc(var(--bottom-nav-height) + 1.5rem + env(safe-area-inset-bottom));
}
.content-narrow { max-width: 760px; padding-bottom: 2rem; }

.bottom-nav {
    position: fixed; inset: auto 0 0 0; z-index: 20;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--color-surface) 94%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid var(--color-border);
}
.bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-width: 0; font-size: .68rem; font-weight: 600; color: var(--color-text-muted);
}
.bottom-nav-item:hover { text-decoration: none; }
.bottom-nav-item.active { color: var(--color-primary); }
.bottom-nav-icon { position: relative; display: inline-flex; }

.nav-badge {
    margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .7rem; font-weight: 700; color: #fff; background: var(--color-primary); border-radius: var(--radius-full);
}
.nav-badge-floating { position: absolute; top: -6px; right: -12px; margin: 0; border: 2px solid var(--color-surface); }

/* Escritorio y tablet: barra lateral */
@media (min-width: 768px) {
    .topbar, .bottom-nav { display: none; }

    .app-shell { display: grid; grid-template-columns: var(--sidebar-compact-width) 1fr; }

    .sidebar {
        position: sticky; top: 0; height: 100dvh;
        display: flex; flex-direction: column; gap: 1rem;
        padding: 1.25rem .75rem;
        background: var(--color-surface); border-right: 1px solid var(--color-border);
    }
    .sidebar .brand span, .sidebar .nav-item span, .sidebar-user-name, .connection-hint { display: none; }
    .sidebar .brand { justify-content: center; }

    .sidebar-nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; overflow-y: auto; }
    .nav-item {
        position: relative; display: flex; align-items: center; justify-content: center; gap: .75rem;
        padding: .7rem; border-radius: var(--radius); color: var(--color-text-muted); font-weight: 600;
    }
    .nav-item:hover { background: var(--color-surface-2); color: var(--color-text); text-decoration: none; }
    .nav-item.active { background: var(--color-primary-soft); color: var(--color-primary); }
    .sidebar .nav-item .nav-badge { position: absolute; top: 4px; right: 4px; }
    .nav-separator { height: 1px; background: var(--color-border); margin: .5rem 0; }

    .sidebar-footer { display: flex; flex-direction: column; gap: .5rem; }
    .sidebar-user { display: flex; flex-direction: column; align-items: center; gap: .5rem; }

    .content { padding: 2rem 2rem 3rem; }
}

@media (min-width: 1100px) {
    .app-shell { grid-template-columns: var(--sidebar-width) 1fr; }
    .sidebar { padding: 1.5rem 1rem; }
    .sidebar .brand span, .sidebar .nav-item span, .sidebar-user-name, .connection-hint { display: inline; }
    .sidebar .brand { justify-content: flex-start; padding: 0 .5rem; }
    .nav-item { justify-content: flex-start; padding: .65rem .85rem; }
    .sidebar .nav-item .nav-badge { position: static; }
    .sidebar-user { flex-direction: row; padding: .5rem; border-radius: var(--radius); background: var(--color-surface-2); }
    .sidebar-user-name { flex: 1; font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .connection-hint { display: flex; align-items: center; gap: .5rem; font-size: .8rem; color: var(--color-warning); padding: 0 .5rem; }
}

/* Páginas públicas (legales, 404) */
.public-shell { min-height: 100dvh; }
.public-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem clamp(1rem, 4vw, 2rem); border-bottom: 1px solid var(--color-border); background: var(--color-surface);
}

/* Autenticación */
.auth-shell { min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
.auth-hero { display: none; }
.auth-main {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2rem 1rem calc(2rem + env(safe-area-inset-bottom));
}
.auth-card { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 1.5rem; }
.auth-brand-mobile { align-self: center; }
.auth-brand-row { align-self: center; justify-content: center; }
.auth-footer { margin-top: 2rem; font-size: .85rem; color: var(--color-text-muted); }
.auth-heading { display: flex; flex-direction: column; gap: .35rem; }
.auth-heading p { color: var(--color-text-muted); }
.auth-alt { text-align: center; color: var(--color-text-muted); font-size: .95rem; }

@media (min-width: 960px) {
    .auth-shell { grid-template-columns: minmax(380px, 46%) 1fr; }
    .auth-hero {
        display: flex; align-items: center; padding: 3rem;
        background: var(--gradient-brand); color: #fff; position: relative; overflow: hidden;
    }
    .auth-hero::after {
        content: ""; position: absolute; inset: auto -20% -30% auto; width: 70%; aspect-ratio: 1;
        border-radius: 50%; background: radial-gradient(circle, rgb(255 255 255 / 18%), transparent 70%);
    }
    .auth-hero-content { position: relative; z-index: 1; max-width: 460px; display: flex; flex-direction: column; gap: 1.75rem; }
    .auth-hero-title { font-size: 2.25rem; line-height: 1.15; }
    .auth-hero-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .9rem; font-size: 1.05rem; }
    .auth-hero-list li { display: flex; gap: .75rem; align-items: center; opacity: .95; }
    .auth-brand-mobile { display: none; }
}

/* Encabezado de página */
.page-header { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.25rem; }
.page-header-text { flex: 1; min-width: 0; }
.page-subtitle { color: var(--color-text-muted); margin-top: .2rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
@media (max-width: 599px) {
    .page-header { flex-wrap: wrap; }
    .page-actions { width: 100%; }
}
@media (max-width: 767px) {
    .page-header.mobile-compact { margin-bottom: .75rem; }
    .page-header.mobile-compact .page-subtitle,
    .page-header.mobile-compact .page-actions { display: none; }
}

/* ---------- 4. Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    min-height: 44px; padding: .6rem 1.1rem;
    font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2;
    border: 1px solid transparent; border-radius: var(--radius); cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s, transform .1s;
    text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--color-primary); color: var(--color-on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--color-primary-hover); }
.btn-secondary { background: var(--color-primary-soft); color: var(--color-primary); }
.btn-secondary:hover:not(:disabled) { background: var(--color-primary-soft-strong); }
.btn-outline { background: transparent; color: var(--color-text); border-color: var(--color-border-strong); }
.btn-outline:hover:not(:disabled) { background: var(--color-surface-2); }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--color-surface-2); color: var(--color-text); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.92); }
.btn-danger-outline { background: transparent; color: var(--color-danger); border-color: color-mix(in srgb, var(--color-danger) 45%, transparent); }
.btn-danger-outline:hover:not(:disabled) { background: var(--color-danger-soft); }
.btn-sm { min-height: 36px; padding: .4rem .8rem; font-size: .875rem; }
.btn-lg { min-height: 52px; padding: .8rem 1.4rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; padding: 0; flex-shrink: 0;
    background: transparent; color: var(--color-text-muted);
    border: 0; border-radius: var(--radius-full); cursor: pointer;
}
.btn-icon:hover { background: var(--color-surface-2); color: var(--color-text); text-decoration: none; }
.btn-icon:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon-sm { width: 32px; height: 32px; }

.button-row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.button-row-end { justify-content: flex-end; }

/* ---------- 5. Formularios ---------- */
.form { display: flex; flex-direction: column; gap: 1rem; }
.form-grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-grid-2 { grid-template-columns: 1fr 1fr; } }

.field { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.field > label, .field-label { font-size: .875rem; font-weight: 600; color: var(--color-text); }
.field-required::after { content: " *"; color: var(--color-danger); }
.field-hint { font-size: .8rem; color: var(--color-text-muted); }
.field-row { display: flex; gap: .75rem; align-items: flex-end; }
.field-row > .field { flex: 1; }

.input, input.input, select.input, textarea.input,
.form input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
.form select, .form textarea {
    width: 100%; min-height: 44px; padding: .6rem .8rem;
    font: inherit; font-size: 1rem; color: var(--color-text);
    background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius);
    transition: border-color .15s, box-shadow .15s;
}
textarea.input, .form textarea { min-height: 110px; resize: vertical; }
.input:focus, .form input:focus, .form select:focus, .form textarea:focus {
    outline: none; border-color: var(--color-primary); box-shadow: var(--focus-ring);
}
.input::placeholder, .form input::placeholder, .form textarea::placeholder { color: var(--color-text-subtle); }

.form .invalid, .input.invalid { border-color: var(--color-danger); }
.validation-message { font-size: .8rem; color: var(--color-danger); }
.validation-errors { margin: 0; padding: .75rem 1rem .75rem 2rem; background: var(--color-danger-soft); color: var(--color-danger); border-radius: var(--radius); font-size: .9rem; }

.password-input { position: relative; }
.password-input .input { padding-right: 3rem; }
.password-input .btn-icon { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); }

.checkbox { display: flex; gap: .65rem; align-items: flex-start; font-size: .92rem; cursor: pointer; }
.checkbox input { width: 20px; height: 20px; margin-top: 2px; flex-shrink: 0; accent-color: var(--color-primary); }

input[type="range"] { width: 100%; accent-color: var(--color-primary); }

.segmented {
    display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px;
    background: var(--color-surface-2); border-radius: var(--radius); width: 100%;
}
.segmented button {
    min-height: 38px; border: 0; border-radius: calc(var(--radius) - 4px); background: transparent;
    font: inherit; font-weight: 600; font-size: .9rem; color: var(--color-text-muted); cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--color-surface); color: var(--color-primary); box-shadow: var(--shadow-sm); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; }
.switch input {
    appearance: none; width: 46px; height: 28px; border-radius: var(--radius-full); flex-shrink: 0;
    background: var(--color-border-strong); position: relative; cursor: pointer; transition: background .15s;
}
.switch input::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
    background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s;
}
.switch input:checked { background: var(--color-primary); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 6. Componentes ---------- */
.card {
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: var(--radius-lg); padding: 1.25rem; box-shadow: var(--shadow-sm);
}
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.card-title { font-size: 1.05rem; font-weight: 700; }
.card-subtitle { color: var(--color-text-muted); font-size: .9rem; margin-top: .15rem; }
.card-section + .card-section { border-top: 1px solid var(--color-border); margin-top: 1.25rem; padding-top: 1.25rem; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack-lg { display: flex; flex-direction: column; gap: 1.5rem; }
.stack-sm { display: flex; flex-direction: column; gap: .5rem; }

.grid-cards { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); }

.alert {
    display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem;
    border-radius: var(--radius); font-size: .92rem; border: 1px solid transparent;
}
.alert .icon { flex-shrink: 0; margin-top: 1px; }
.alert-content { flex: 1; display: flex; flex-direction: column; gap: .5rem; }
.alert-info { background: var(--color-primary-soft); color: var(--color-text); border-color: var(--color-primary-soft-strong); }
.alert-info .icon { color: var(--color-primary); }
.alert-success { background: var(--color-success-soft); color: var(--color-success); }
.alert-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.alert-danger { background: var(--color-danger-soft); color: var(--color-danger); }

.badge {
    display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem;
    font-size: .75rem; font-weight: 700; border-radius: var(--radius-full);
    background: var(--color-surface-2); color: var(--color-text-muted); white-space: nowrap;
}
.badge-primary { background: var(--color-primary-soft); color: var(--color-primary); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .8rem;
    font-size: .85rem; font-weight: 500; border-radius: var(--radius-full);
    background: var(--color-surface-2); color: var(--color-text); border: 1px solid var(--color-border);
}
.chip-highlight { background: var(--color-primary-soft); border-color: var(--color-primary-soft-strong); color: var(--color-primary); font-weight: 600; }
.chip-select { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip-toggle { cursor: pointer; font: inherit; font-size: .88rem; min-height: 38px; transition: all .15s; }
.chip-toggle:hover:not(:disabled) { border-color: var(--color-primary); }
.chip-toggle.selected { background: var(--color-primary); border-color: var(--color-primary); color: var(--color-on-primary); }
.chip-toggle:disabled { opacity: .45; cursor: not-allowed; }

.avatar {
    position: relative; display: inline-flex; flex-shrink: 0;
    width: var(--avatar-size); height: var(--avatar-size); border-radius: 50%;
    background: var(--gradient-brand); color: #fff;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.avatar-initials { margin: auto; font-weight: 700; font-size: calc(var(--avatar-size) * .38); }
.avatar-badge {
    position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .7rem; font-weight: 700; color: #fff; background: var(--color-primary);
    border: 2px solid var(--color-surface); border-radius: var(--radius-full);
}

.facts { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem 1rem; color: var(--color-text-muted); font-size: .9rem; }
.facts li { display: inline-flex; align-items: center; gap: .35rem; }
.profile-details { display: flex; flex-direction: column; gap: .9rem; }
.profile-bio { white-space: pre-line; }

.carousel { position: relative; overflow: hidden; background: var(--color-surface-2); aspect-ratio: 4 / 5; border-radius: var(--radius-lg); }
.carousel-image { width: 100%; height: 100%; object-fit: cover; user-select: none; }
.carousel-empty { display: grid; place-items: center; height: 100%; }
.carousel-dots { position: absolute; top: 10px; left: 12px; right: 12px; display: flex; gap: 4px; z-index: 2; }
.carousel-dot { flex: 1; height: 3px; border-radius: 2px; background: rgb(255 255 255 / 45%); }
.carousel-dot.active { background: #fff; }
.carousel-zone { position: absolute; top: 0; bottom: 30%; width: 50%; border: 0; background: transparent; cursor: pointer; z-index: 1; }
.carousel-prev { left: 0; }
.carousel-next { right: 0; }

.location-picker { display: grid; gap: .75rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .location-picker { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); } }

.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: .9rem; padding: .85rem 0; border-bottom: 1px solid var(--color-border); }
.list-item:last-child { border-bottom: 0; }
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; }
.list-item-meta { font-size: .85rem; color: var(--color-text-muted); }

.table-wrap { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--color-border); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--color-text-muted); background: var(--color-surface-2); font-weight: 700; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--color-surface-2); }
.table .cell-actions { text-align: right; white-space: nowrap; }
.table-muted { opacity: .55; }

/* En celular, cada fila de la tabla se muestra como tarjeta */
@media (max-width: 719px) {
    .table-responsive thead { display: none; }
    .table-responsive, .table-responsive tbody, .table-responsive tr, .table-responsive td { display: block; width: 100%; }
    .table-responsive tr { padding: .75rem 1rem; border-bottom: 1px solid var(--color-border); }
    .table-responsive td { border: 0; padding: .2rem 0; }
    .table-responsive td[data-label]::before { content: attr(data-label) ": "; font-weight: 600; color: var(--color-text-muted); font-size: .8rem; }
    .table-responsive .cell-actions { text-align: left; padding-top: .5rem; }
}

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--color-border); margin-bottom: 1.25rem; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
    padding: .7rem 1rem; border: 0; border-bottom: 2px solid transparent; background: transparent;
    font: inherit; font-weight: 600; font-size: .92rem; color: var(--color-text-muted); cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--color-text); text-decoration: none; }
.tab.active, .tab[aria-selected="true"] { color: var(--color-primary); border-bottom-color: var(--color-primary); }

.pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; }
.pagination-info { font-size: .9rem; color: var(--color-text-muted); }

.modal-backdrop {
    position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
    background: rgb(8 15 30 / 55%); animation: fade-in .15s ease-out;
}
.modal {
    width: 100%; max-height: 92dvh; display: flex; flex-direction: column;
    background: var(--color-surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    box-shadow: var(--shadow-lg); animation: slide-up .2s ease-out; outline: none;
    padding-bottom: env(safe-area-inset-bottom);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.1rem 1.25rem .5rem; }
.modal-title { font-size: 1.15rem; }
.modal-body { padding: .5rem 1.25rem 1.25rem; overflow-y: auto; }
.modal-footer { display: flex; gap: .75rem; justify-content: flex-end; padding: 1rem 1.25rem; border-top: 1px solid var(--color-border); flex-wrap: wrap; }
.confirm-text { color: var(--color-text-muted); }
@media (min-width: 640px) {
    .modal-backdrop { align-items: center; padding: 1.5rem; }
    .modal { max-width: 540px; border-radius: var(--radius-xl); }
    .modal-sm { max-width: 420px; }
    .modal-lg { max-width: 760px; }
}

.toast-host {
    position: fixed; z-index: 60; left: 1rem; right: 1rem;
    bottom: calc(var(--bottom-nav-height) + 1rem + env(safe-area-inset-bottom));
    display: flex; flex-direction: column; gap: .5rem; pointer-events: none;
}
@media (min-width: 768px) { .toast-host { left: auto; right: 1.5rem; bottom: 1.5rem; width: 380px; } }
.toast {
    pointer-events: auto; display: flex; align-items: center; gap: .75rem;
    padding: .75rem .75rem .75rem 1rem; border-radius: var(--radius);
    background: var(--color-text); color: var(--color-bg); box-shadow: var(--shadow-lg);
    font-size: .92rem; animation: slide-up .2s ease-out;
}
.toast-message { flex: 1; }
.toast .btn-icon { color: inherit; opacity: .7; }
.toast .btn-icon:hover { background: rgb(255 255 255 / 12%); opacity: 1; }
.toast-success .icon { color: #4ade80; }
.toast-error .icon, .toast-warning .icon { color: #fbbf24; }
.toast-info .icon { color: var(--blue-300); }
.toast-action { font-weight: 700; color: var(--blue-300); white-space: nowrap; }

.markdown { line-height: 1.65; }
.markdown h1, .markdown h2, .markdown h3 { margin: 1.25rem 0 .5rem; }
.markdown p, .markdown ul, .markdown ol { margin: 0 0 .85rem; }
.markdown table { border-collapse: collapse; width: 100%; margin-bottom: 1rem; }
.markdown th, .markdown td { border: 1px solid var(--color-border); padding: .4rem .6rem; }

.spinner {
    display: inline-block; width: var(--spinner-size); height: var(--spinner-size); flex-shrink: 0;
    border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
    animation: spin .7s linear infinite; opacity: .8;
}

.icon { flex-shrink: 0; }

/* ---------- 7. Estados y utilidades ---------- */
.state {
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
    gap: .75rem; padding: 3rem 1rem; color: var(--color-text-muted); max-width: 460px; margin: 0 auto;
}
.state-icon {
    display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%;
    background: var(--color-primary-soft); color: var(--color-primary); margin-bottom: .25rem;
}
.state-error .state-icon { background: var(--color-danger-soft); color: var(--color-danger); }
.state-title { color: var(--color-text); }
.state-actions { display: flex; gap: .75rem; flex-wrap: wrap; justify-content: center; margin-top: .5rem; }
.state-loading { color: var(--color-primary); }

.muted { color: var(--color-text-muted); }
.subtle { color: var(--color-text-subtle); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(16px); opacity: 0; } }

/* Splash y error global de Blazor */
.splash {
    min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
    background: var(--gradient-brand); color: #fff; font-weight: 700; font-size: 1.4rem;
}
/* Primera carga lenta (túnel): el texto aparece a los 3 s */
.splash-slow { max-width: 260px; text-align: center; font-size: .9rem; opacity: 0; animation: splash-slow .4s ease 3s forwards; }
@keyframes splash-slow { to { opacity: .85; } }
.splash-bar { width: 120px; height: 4px; border-radius: 2px; background: rgb(255 255 255 / 25%); overflow: hidden; }
.splash-bar::after { content: ""; display: block; width: 40%; height: 100%; background: #fff; animation: splash 1.1s ease-in-out infinite; }
@keyframes splash { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

#blazor-error-ui {
    display: none; position: fixed; inset: auto 0 0 0; z-index: 100;
    padding: .9rem 1.25rem calc(.9rem + env(safe-area-inset-bottom));
    background: var(--color-danger); color: #fff; box-shadow: var(--shadow-lg);
}
#blazor-error-ui a { color: #fff; font-weight: 700; text-decoration: underline; margin-left: .5rem; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }
