/* =========================================================================
   Genesys · Sistema de diseño
   Tokens de marca tomados del logo oficial (#FF451A / #0B1228) y del lookbook.
   ========================================================================= */

:root {
    --brand: #FF451A;
    --brand-600: #E83A10;
    --brand-700: #C4300C;
    --brand-50: #FFF2ED;
    --brand-100: #FFE1D6;
    --ink: #0B1228;
    --ink-2: #333A4F;
    --muted: #6B7285;
    --subtle: #9197A6;
    --line: #E6E7EB;
    --line-strong: #D2D5DC;
    --bg: #F5F5F5;
    --surface: #FFFFFF;
    --surface-2: #EBEBED;
    --surface-3: #F7F7F8;
    --sky: #C5D7E6;
    --sky-50: #EEF4F9;
    --sky-700: #2B5673;
    --slate: #8C93A3;
    --slate-50: #EFF0F3;
    --slate-700: #474E60;
    --ok: #177A4B;
    --ok-50: #E7F5EE;
    --danger: #C62828;
    --danger-50: #FDEDED;

    --font: "Roboto", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    --mono: "Roboto Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-xs: 0 1px 2px rgba(11, 18, 40, .06);
    --shadow-sm: 0 1px 2px rgba(11, 18, 40, .05), 0 2px 8px -2px rgba(11, 18, 40, .08);
    --shadow: 0 10px 30px -12px rgba(11, 18, 40, .22), 0 2px 6px rgba(11, 18, 40, .05);
    --shadow-lg: 0 30px 60px -20px rgba(11, 18, 40, .35);
    --ring: 0 0 0 4px rgba(255, 69, 26, .18);
    --ease: cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Base ---------- */

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.01em; }
img, svg { display: block; max-width: 100%; }
a { color: var(--brand-600); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Blazor enfoca el título al navegar (lectores de pantalla); no hace falta mostrar el anillo. */
h1[tabindex="-1"]:focus, h1:focus { outline: none; }
::selection { background: var(--brand-100); }

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

.muted { color: var(--muted); }
.mono { font-family: var(--mono); letter-spacing: .04em; }
.nowrap { white-space: nowrap; }

/* ---------- Botones ---------- */

.btn {
    --btn-bg: var(--surface);
    --btn-fg: var(--ink);
    --btn-bd: var(--line-strong);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    min-height: 44px;
    padding: .625rem 1.25rem;
    border: 1px solid var(--btn-bd);
    border-radius: var(--radius-sm);
    background: var(--btn-bg);
    color: var(--btn-fg);
    font-weight: 600;
    font-size: .95rem;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    transition: background-color .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease), transform .12s var(--ease), color .18s var(--ease);
}
.btn:hover { --btn-bg: var(--surface-3); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn--primary { --btn-bg: var(--brand); --btn-fg: #fff; --btn-bd: var(--brand); box-shadow: 0 6px 16px -8px rgba(255, 69, 26, .7); }
.btn--primary:hover { --btn-bg: var(--brand-600); --btn-bd: var(--brand-600); }
.btn--primary:active { --btn-bg: var(--brand-700); }
.btn--primary[disabled] { box-shadow: none; }

.btn--muted { --btn-bg: var(--surface-2); --btn-fg: var(--ink); --btn-bd: transparent; }
.btn--muted:hover { --btn-bg: #E2E2E5; }

.btn--dark { --btn-bg: var(--ink); --btn-fg: #fff; --btn-bd: var(--ink); }
.btn--dark:hover { --btn-bg: #1B2440; }

.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--ink-2); }
.btn--ghost:hover { --btn-bg: rgba(11, 18, 40, .05); }

.btn--danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-bd: var(--danger); }
.btn--danger:hover { --btn-bg: #A91F1F; }

.btn--sm { min-height: 36px; padding: .45rem .85rem; font-size: .875rem; border-radius: 8px; }
.btn--lg { min-height: 52px; padding: .8rem 1.75rem; font-size: 1rem; letter-spacing: .02em; }
.btn--xl { min-height: 64px; padding: 1rem 2rem; font-size: 1.25rem; font-weight: 700; border-radius: var(--radius); }
.btn--block { display: flex; width: 100%; }
.btn--upper { text-transform: uppercase; letter-spacing: .06em; }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 36px; height: 36px;
    border: 0; border-radius: 9px;
    background: transparent; color: var(--muted);
    transition: background-color .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: rgba(11, 18, 40, .06); color: var(--ink); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn--danger:hover { background: var(--danger-50); color: var(--danger); }

.link-btn {
    border: 0; background: none; padding: .25rem 0;
    color: var(--muted); font-size: .925rem; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--ink); }

/* ---------- Spinner ---------- */

.spinner {
    width: 18px; height: 18px; flex: none;
    border: 2.5px solid currentColor; border-right-color: transparent;
    border-radius: 50%;
    animation: girar .7s linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- Campos ---------- */

.field { display: grid; gap: .4rem; }
.field__label {
    font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--subtle);
}
.field__req { color: var(--brand); }
.field__input {
    width: 100%;
    min-height: 52px;
    padding: .75rem 1rem;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--ink);
    font-size: 1.0625rem;
    font-weight: 500;
    transition: border-color .18s var(--ease), background-color .18s var(--ease), box-shadow .18s var(--ease);
}
.field__input::placeholder { color: #A3A8B5; font-weight: 400; }
.field__input:hover { background: #E5E5E8; }
.field__input:focus { outline: none; background: var(--surface); border-color: var(--ink); box-shadow: var(--ring); }
.field__input[aria-invalid="true"] { border-color: var(--danger); background: var(--surface); }
.field__input:disabled { opacity: .7; }
.field__input--light { background: var(--surface); border: 1.5px solid var(--line-strong); min-height: 46px; font-size: 1rem; }
.field__input--light:hover { background: var(--surface); border-color: var(--slate); }
.field__input--light:focus { border-color: var(--ink); }
.field__help { font-size: .82rem; color: var(--muted); }
.field__error {
    display: flex; align-items: flex-start; gap: .45rem;
    font-size: .9rem; color: var(--danger);
}
.field__error svg { width: 16px; height: 16px; margin-top: .15rem; flex: none; }
.validation-message { font-size: .85rem; color: var(--danger); }

.check { display: flex; align-items: flex-start; gap: .65rem; cursor: pointer; font-size: .95rem; }
.check input { width: 18px; height: 18px; margin: .15rem 0 0; accent-color: var(--brand); flex: none; }

/* ---------- Alertas ---------- */

.alert {
    display: flex; gap: .7rem; align-items: flex-start;
    padding: .85rem 1rem;
    border-radius: var(--radius-sm);
    font-size: .925rem;
    border: 1px solid transparent;
}
.alert svg { width: 18px; height: 18px; flex: none; margin-top: .1rem; }
.alert--error { background: var(--danger-50); color: #8E1C1C; border-color: #F6CFCF; }
.alert--ok { background: var(--ok-50); color: #125C39; border-color: #C9E8D7; }
.alert--info { background: var(--sky-50); color: var(--sky-700); border-color: #D7E5F0; }
.alert--warn { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }

/* ---------- Tarjetas ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

/* ---------- Barra de progreso ---------- */

.progress { display: grid; gap: .5rem; width: 100%; }
.progress__track {
    position: relative;
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(11, 18, 40, .08);
}
.progress--lg .progress__track { height: 10px; }
.progress--thin .progress__track { height: 3px; border-radius: 0; background: rgba(255, 69, 26, .12); }
.progress__bar {
    position: absolute; inset: 0 auto 0 0;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #FF7A45, var(--brand) 60%, var(--brand-600));
    transition: width .35s var(--ease);
}
.progress__bar::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
    transform: translateX(-100%);
    animation: brillo 1.4s ease-in-out infinite;
}
.progress--indeterminate .progress__bar {
    width: 38%;
    animation: indeterminado 1.15s var(--ease) infinite;
}
.progress--indeterminate .progress__bar::after { display: none; }
.progress__meta {
    display: flex; justify-content: space-between; gap: 1rem;
    font-size: .85rem; color: var(--muted);
}
.progress__meta strong { color: var(--ink); font-variant-numeric: tabular-nums; }

@keyframes indeterminado {
    0% { left: -40%; }
    100% { left: 100%; }
}
@keyframes brillo { to { transform: translateX(100%); } }

/* Barra fija superior para cargas de página */
.top-loader { position: fixed; inset: 0 0 auto 0; z-index: 60; pointer-events: none; }

/* ---------- Chips de estado ---------- */

.chip {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .22rem .6rem .22rem .5rem;
    border-radius: 999px;
    font-size: .8rem; font-weight: 600;
    white-space: nowrap;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .9; }
.chip--si { background: var(--brand-50); color: var(--brand-700); }
.chip--no { background: var(--slate-50); color: var(--slate-700); }
.chip--pendiente { background: var(--sky-50); color: var(--sky-700); }
.chip--ok { background: var(--ok-50); color: var(--ok); }

/* ---------- Modal ---------- */

.modal-root {
    position: fixed; inset: 0; z-index: 80;
    display: grid; place-items: center;
    padding: 1rem;
}
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(11, 18, 40, .45);
    backdrop-filter: blur(3px);
    animation: aparecer .2s var(--ease);
}
.modal {
    position: relative;
    width: min(100%, 480px);
    max-height: calc(100dvh - 2rem);
    overflow: auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: subir .28s var(--ease);
}
.modal--sm { width: min(100%, 400px); }
.modal__header {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 1.25rem 1.25rem .5rem 1.5rem;
}
.modal__header h2 { font-size: 1.15rem; }
.modal__body { padding: .5rem 1.5rem 1.25rem; display: grid; gap: 1rem; }
.modal__footer {
    display: flex; justify-content: flex-end; gap: .6rem; flex-wrap: wrap;
    padding: 1rem 1.5rem 1.25rem;
    border-top: 1px solid var(--line);
    background: var(--surface-3);
}

@keyframes aparecer { from { opacity: 0; } }
@keyframes subir { from { opacity: 0; transform: translateY(12px) scale(.98); } }

/* ---------- Error global de Blazor ---------- */

#blazor-error-ui {
    position: fixed; left: 50%; bottom: 1rem; z-index: 1000;
    display: none;
    width: min(calc(100% - 2rem), 560px);
    transform: translateX(-50%);
    padding: .9rem 3rem .9rem 1.1rem;
    border-radius: var(--radius-sm);
    background: var(--ink); color: #fff;
    box-shadow: var(--shadow-lg);
    font-size: .95rem;
}
#blazor-error-ui .reload { color: #FFB39E; font-weight: 600; margin-left: .35rem; }
#blazor-error-ui .dismiss {
    position: absolute; right: .9rem; top: 50%; transform: translateY(-50%);
    cursor: pointer; opacity: .7;
}

/* ---------- Movimiento reducido ---------- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
