/* =========================================================
   BullSemen · Pantalla de acceso
   ========================================================= */

:root {
    --font-display: "Sora", system-ui, sans-serif;
    --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;

    /* Marca (fija: el panel izquierdo siempre es oscuro) */
    --ink-900: #07111f;
    --ink-800: #0c1a2e;
    --cryo-300: #7dd3fc;
    --cryo-400: #38bdf8;
    --cryo-500: #0ea5e9;
    --teal-300: #5eead4;
    --teal-500: #14b8a6;

    /* Tema claro */
    --bg: #f3f6fa;
    --surface: #ffffff;
    --surface-2: #f6f8fb;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #5b6b80;
    --text-soft: #8a99ad;
    --accent: #0284c7;
    --accent-strong: #0369a1;
    --ring: rgba(14, 165, 233, .22);
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --shadow-card: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 40px -12px rgba(15, 23, 42, .14);

    --radius: 14px;
    --ease-out: cubic-bezier(.22, 1, .36, 1);
    color-scheme: light;
}

/* Tema claro por defecto; el oscuro solo con el botón de tema */
:root[data-theme="dark"] {
    --bg: #081221;
    --surface: #0f1b2d;
    --surface-2: #0b1626;
    --border: #1d2b40;
    --border-strong: #2a3b54;
    --text: #e8eef6;
    --text-muted: #94a3b8;
    --text-soft: #64748b;
    --accent: #38bdf8;
    --accent-strong: #7dd3fc;
    --ring: rgba(56, 189, 248, .25);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, .08);
    --danger-border: rgba(248, 113, 113, .3);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .3), 0 20px 50px -20px rgba(0, 0, 0, .6);
    color-scheme: dark;
}

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

html, body { height: 100%; }

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

svg { display: block; }
img { max-width: 100%; display: block; }

/* =========================================================
   Layout
   ========================================================= */

.auth {
    position: relative;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(420px, 1fr);
}

/* ---------- Panel de marca ---------- */

.brand {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    color: #e6f1fb;
    background:
        radial-gradient(900px 600px at 0% 0%, rgba(14, 165, 233, .28), transparent 60%),
        radial-gradient(700px 500px at 100% 100%, rgba(20, 184, 166, .22), transparent 60%),
        linear-gradient(160deg, var(--ink-800), var(--ink-900) 60%);
}

.brand__bg { position: absolute; inset: 0; z-index: -1; }

.brand__grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(125, 211, 252, .06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(125, 211, 252, .06) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 75%);
}

.bubble {
    position: absolute;
    bottom: -20px;
    left: var(--x);
    width: var(--s);
    height: var(--s);
    border-radius: 50%;
    border: 1px solid rgba(186, 230, 253, .45);
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, .5), rgba(125, 211, 252, .08) 60%);
    animation: rise var(--d) linear var(--delay) infinite;
    opacity: 0;
}

@keyframes rise {
    0%   { transform: translate3d(0, 0, 0); opacity: 0; }
    10%  { opacity: .9; }
    90%  { opacity: .6; }
    100% { transform: translate3d(14px, -105vh, 0); opacity: 0; }
}

.brand__inner {
    position: relative;
    height: 100%;
    max-width: 620px;
    margin: 0 auto;
    padding: clamp(28px, 5vw, 56px) clamp(24px, 5vw, 64px);
    display: flex;
    flex-direction: column;
    gap: 36px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
    width: fit-content;
}

.logo__text {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    letter-spacing: -.02em;
}

.brand__copy { margin-top: auto; }

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .02em;
    color: var(--cryo-300);
    background: rgba(56, 189, 248, .1);
    border: 1px solid rgba(56, 189, 248, .22);
}

.eyebrow__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--teal-300);
    box-shadow: 0 0 0 4px rgba(94, 234, 212, .18);
}

.brand h1 {
    margin: 20px 0 16px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(30px, 3.4vw, 46px);
    line-height: 1.1;
    letter-spacing: -.03em;
    color: #fff;
    text-wrap: balance;
}

.frost {
    background: linear-gradient(90deg, var(--cryo-300), var(--teal-300));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.brand__lead {
    margin: 0;
    max-width: 46ch;
    font-size: 16px;
    color: #a9bdd3;
}

/* ---------- Tarjeta ilustrativa del termo ---------- */

.tank-card {
    padding: 18px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, .07), rgba(255, 255, 255, .03));
    border: 1px solid rgba(186, 230, 253, .14);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .06);
    max-width: 440px;
}

.tank-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.tank-card__label {
    display: block;
    font-size: 12px;
    color: #8ba3bd;
}

.tank-card__title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    color: #fff;
}

.chip {
    font-size: 11.5px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
}

.chip--ok {
    color: var(--teal-300);
    background: rgba(94, 234, 212, .12);
    border: 1px solid rgba(94, 234, 212, .25);
}

.tank-card__body {
    display: grid;
    grid-template-columns: 54px 1fr;
    gap: 18px;
    align-items: end;
    margin: 16px 0 12px;
}

.tank {
    position: relative;
    height: 96px;
    border-radius: 14px 14px 18px 18px;
    border: 1.5px solid rgba(186, 230, 253, .35);
    overflow: hidden;
    background: rgba(7, 17, 31, .5);
}

.tank::before { /* cuello del termo */
    content: "";
    position: absolute;
    top: -1px;
    left: 50%;
    width: 22px;
    height: 8px;
    transform: translateX(-50%);
    border-radius: 0 0 6px 6px;
    background: rgba(186, 230, 253, .35);
}

.tank__fill {
    position: absolute;
    inset: auto 0 0 0;
    height: 72%;
    background: linear-gradient(180deg, var(--cryo-400), var(--cryo-500) 50%, #0369a1);
    animation: fill 2.4s var(--ease-out) both;
}

.tank__wave {
    position: absolute;
    top: -6px;
    left: -50%;
    width: 200%;
    height: 12px;
    background: radial-gradient(10px 6px at 10px 6px, var(--cryo-400) 98%, transparent) 0 0 / 20px 12px repeat-x;
    animation: wave 3s linear infinite;
}

@keyframes fill { from { height: 8%; } }
@keyframes wave { to { transform: translateX(20px); } }

.spark { width: 100%; height: 80px; overflow: visible; }

.spark__line {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    animation: draw 2s var(--ease-out) .3s forwards;
}

.spark__area { opacity: 0; animation: fade .8s ease 1.4s forwards; }

@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { to { opacity: 1; } }

.tank-card__foot {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #8ba3bd;
}

.tank-card__foot span { display: inline-flex; align-items: center; gap: 6px; }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot--teal { background: var(--teal-300); }

/* ---------- Lista de funciones ---------- */

.features {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.features li { display: grid; gap: 10px; align-content: start; }

.features__icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    color: var(--cryo-300);
    background: rgba(56, 189, 248, .1);
    border: 1px solid rgba(56, 189, 248, .18);
}

.features__icon svg,
.control__icon,
.control__action svg,
.theme-toggle svg,
.btn__arrow,
.alert svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.features__icon svg { width: 19px; height: 19px; }

.features strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.features span:not(.features__icon) {
    font-size: 13px;
    color: #8ba3bd;
}

/* =========================================================
   Panel de acceso
   ========================================================= */

.panel {
    position: relative;
    display: grid;
    place-items: center;
    padding: 40px 24px;
    padding-bottom: max(40px, env(safe-area-inset-bottom));
}

.theme-toggle {
    position: absolute;
    top: max(20px, env(safe-area-inset-top));
    right: 20px;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    z-index: 5;
    transition: color .2s, border-color .2s, transform .15s;
}

.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle svg { width: 19px; height: 19px; }
.theme-toggle .i-sun { display: none; }

:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }

.card {
    width: 100%;
    max-width: 420px;
    animation: enter .7s var(--ease-out) both;
}

@keyframes enter {
    from { opacity: 0; transform: translateY(14px); }
}

.card__head h2 {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 28px;
    letter-spacing: -.025em;
}

.card__head p {
    margin: 0 0 28px;
    color: var(--text-muted);
}

/* ---------- Alerta ---------- */

.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    margin-bottom: 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--danger);
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
}

.alert[hidden] { display: none; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

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

.field { margin-bottom: 18px; }

.field label {
    display: block;
    margin-bottom: 8px;
    font-size: 13.5px;
    font-weight: 600;
}

.field__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.link {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
}

.link:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 3px; }

.control { position: relative; }

.control__icon {
    position: absolute;
    left: 15px;
    top: 50%;
    width: 19px;
    height: 19px;
    transform: translateY(-50%);
    color: var(--text-soft);
    pointer-events: none;
    transition: color .2s;
}

.control input {
    width: 100%;
    height: 52px;
    padding: 0 48px 0 46px;
    font: inherit;
    font-size: 15.5px; /* >=16px efectivo en iOS evita zoom con el viewport */
    color: var(--text);
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color .2s, box-shadow .2s, background-color .2s;
}

.control input::placeholder { color: var(--text-soft); }
.control input:hover { border-color: var(--border-strong); }

.control input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--ring);
}

.control:focus-within .control__icon { color: var(--accent); }

.field.is-invalid .control input {
    border-color: var(--danger);
    box-shadow: 0 0 0 4px var(--danger-bg);
}

.field__error {
    display: block;
    min-height: 0;
    margin-top: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--danger);
}

.field__error:empty { display: none; }

.field__hint {
    display: block;
    margin-top: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: #d97706;
}

.field__hint[hidden] { display: none; }

.control__action {
    position: absolute;
    right: 6px;
    top: 50%;
    width: 40px;
    height: 40px;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-soft);
    cursor: pointer;
}

.control__action:hover { color: var(--text); background: var(--surface-2); }
.control__action svg { width: 19px; height: 19px; }
.control__action .i-eye-off { display: none; }
.control__action[aria-pressed="true"] .i-eye { display: none; }
.control__action[aria-pressed="true"] .i-eye-off { display: block; }

/* ---------- Switch ---------- */

.switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.switch input { position: absolute; opacity: 0; pointer-events: none; }

.switch__track {
    position: relative;
    width: 38px;
    height: 22px;
    flex: none;
    border-radius: 999px;
    background: var(--border-strong);
    transition: background-color .25s var(--ease-out);
}

.switch__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .25s var(--ease-out);
}

.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track .switch__thumb { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { box-shadow: 0 0 0 4px var(--ring); }

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

.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 52px;
    padding: 0 22px;
    font: inherit;
    font-weight: 700;
    font-size: 15.5px;
    border-radius: var(--radius);
    border: 0;
    cursor: pointer;
    transition: transform .15s var(--ease-out), box-shadow .25s, background-color .2s, opacity .2s;
}

.btn:active { transform: scale(.98); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--ring); }

.btn--primary {
    width: 100%;
    color: #fff;
    background: linear-gradient(135deg, var(--cryo-500), #0284c7 55%, var(--teal-500));
    box-shadow: 0 10px 24px -10px rgba(2, 132, 199, .7), inset 0 1px 0 rgba(255, 255, 255, .2);
}

.btn--primary:hover { box-shadow: 0 14px 30px -10px rgba(2, 132, 199, .85), inset 0 1px 0 rgba(255, 255, 255, .2); }

.btn__arrow {
    width: 18px;
    height: 18px;
    stroke-width: 2.2;
    transition: transform .25s var(--ease-out);
}

.btn--primary:hover .btn__arrow { transform: translateX(3px); }

.btn__spinner {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2.5px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    opacity: 0;
    animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn.is-loading { pointer-events: none; }
.btn.is-loading .btn__label,
.btn.is-loading .btn__arrow { opacity: 0; }
.btn.is-loading .btn__spinner { opacity: 1; }

.btn.is-success { background: linear-gradient(135deg, var(--teal-500), #0d9488); }

.btn--ghost {
    height: 40px;
    padding: 0 16px;
    font-size: 14px;
    color: var(--accent);
    background: var(--surface);
    border: 1.5px solid var(--border);
}

.btn--ghost:hover { border-color: var(--accent); }

/* ---------- Instalar PWA ---------- */

.install {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 24px;
    padding: 14px 14px 14px 16px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px dashed var(--border-strong);
    animation: enter .5s var(--ease-out) both;
}

.install[hidden] { display: none; }
.install__text strong { display: block; font-size: 14px; }
.install__text span { font-size: 13px; color: var(--text-muted); }

.volver {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 22px;
    padding: 10px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: color .2s, background-color .2s;
}
.volver svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.volver:hover, .volver:focus-visible { color: var(--accent); background: var(--surface-2); }

.card__foot {
    margin-top: 14px;
    text-align: center;
    font-size: 12.5px;
    color: var(--text-soft);
}

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: max(24px, env(safe-area-inset-bottom));
    transform: translate(-50%, 20px);
    max-width: calc(100% - 32px);
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: #0f172a;
    box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .5);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s, transform .35s var(--ease-out);
    z-index: 50;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Animación de error ---------- */

.shake { animation: shake .4s var(--ease-out); }

@keyframes shake {
    20% { transform: translateX(-8px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(2px); }
}

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1180px) {
    .features { grid-template-columns: 1fr; gap: 14px; }
    .features li { grid-template-columns: 38px 1fr; align-items: center; gap: 14px; }
}

/* Tablet y móvil: el panel de marca pasa a ser cabecera */
@media (max-width: 960px) {
    .auth {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .brand__inner {
        max-width: none;
        padding: max(22px, env(safe-area-inset-top)) 24px 64px;
        gap: 0;
    }

    .brand__copy { margin-top: 36px; }
    .brand h1 { font-size: clamp(26px, 6vw, 36px); margin: 16px 0 10px; }
    .brand__lead { font-size: 14.5px; }

    .tank-card,
    .features { display: none; }

    .panel {
        place-items: start center;
        margin-top: -32px;
        padding: 32px 24px 40px;
        border-radius: 28px 28px 0 0;
        background: var(--bg);
        box-shadow: 0 -12px 30px -16px rgba(0, 0, 0, .35);
    }

    /* Sobre la cabecera oscura */
    .theme-toggle {
        top: max(18px, env(safe-area-inset-top));
        right: 18px;
        color: #cfe6f8;
        background: rgba(255, 255, 255, .08);
        border-color: rgba(186, 230, 253, .18);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    .theme-toggle:hover { color: #fff; border-color: rgba(186, 230, 253, .35); }
}

@media (max-width: 960px) and (min-width: 600px) {
    .card {
        max-width: 480px;
        margin-top: 8px;
        padding: 36px;
        border-radius: 22px;
        background: var(--surface);
        border: 1px solid var(--border);
        box-shadow: var(--shadow-card);
    }
}

@media (max-width: 480px) {
    .brand__lead { display: none; }
    .brand__copy { margin-top: 28px; }
    .brand__inner { padding-bottom: 56px; }
    .card__head h2 { font-size: 24px; }
    .card__head p { margin-bottom: 22px; }
    .panel { padding: 28px 20px 32px; }
}

/* Pantallas bajas en horizontal (móvil acostado) */
@media (max-width: 960px) and (max-height: 520px) {
    .brand__copy { display: none; }
    .brand__inner { padding-bottom: 48px; }
}

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