/* YC Proyectos · estilos
   Sistema visual de YC (diseno-ui/DISENO_UI.md): paleta "Dosímetro" + "Esquina recortada".
   Es el de las NUI de FiveM llevado a una web: las medidas van en rem (no con la altura de la
   pantalla), los campos de texto usan 16 px para que el móvil no haga zoom al escribir y todo lo
   que se pulsa mide al menos 44 px. */

@font-face { font-family: 'Chakra Petch'; font-weight: 500; font-display: swap; src: url('fonts/ChakraPetch-Medium.woff2') format('woff2'); }
@font-face { font-family: 'Chakra Petch'; font-weight: 700; font-display: swap; src: url('fonts/ChakraPetch-Bold.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 500; font-display: swap; src: url('fonts/JetBrainsMono-Medium.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 700; font-display: swap; src: url('fonts/JetBrainsMono-Bold.woff2') format('woff2'); }

:root {
    /* Paleta Dosímetro */
    --ground: #0e0f0c;       /* fondo */
    --surface: #161813;      /* paneles y tarjetas */
    --surface-2: #1f221b;    /* campos, hover */
    --line: #2c3026;         /* separadores */
    --edge: #6b705f;         /* contorno de botones, campos y paneles */
    --text: #e6e8dd;
    --dim: #a3a797;          /* etiquetas, fechas, ayudas */
    --accent: #e8f23a;       /* botón principal, selección y foco */
    --accent-hover: #f2f86e;
    --ink: #0e0f0c;          /* texto sobre el acento */

    /* Señales: solo para estados, y siempre con texto o icono */
    --danger: #e5484d;
    --danger-fill: #2a1514;
    --warning: #f0a33a;
    --info: #38b6e0;
    --success: #7bd88f;
    --backdrop: rgba(10, 11, 9, 0.72);

    --font: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
    --mono: 'JetBrains Mono', Consolas, ui-monospace, monospace;

    /* Corte de la esquina superior derecha */
    --notch-panel: 1rem;
    --notch-control: 0.625rem;
    --notch-field: 0.5rem;

    --touch: 2.75rem;        /* 44 px: alto mínimo de lo que se pulsa */
    --page-pad: 1rem;
    --page-max: 72rem;

    color-scheme: dark;
}

@media (min-width: 60rem) {
    :root { --page-pad: 1.5rem; }
}

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

/* hidden gana aunque la clase ponga display: flex */
[hidden] {
    display: none !important;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    background: var(--ground);
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--ground);
    color: var(--text);
    font-family: var(--font);
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

::selection { background: var(--accent); color: var(--ink); }

button,
input,
textarea {
    font: inherit;
    color: inherit;
}

svg { display: block; flex: none; }

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

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

/* ── Esquina recortada ─────────────────────────────────────────────────────
   Dos capas, como en yc-ui.css: el elemento pinta el borde (--border) y ::before el relleno (--fill)
   1 px hacia dentro, así la diagonal del corte también lleva borde. El relleno tiene que ser opaco
   y outline no se ve (lo corta el recorte): el foco se marca cambiando --border. */
.cut {
    --cut: var(--notch-control);
    --fill: var(--surface);
    --border: var(--edge);
    position: relative;
    isolation: isolate;
    background: var(--border);
    clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
}

.cut::before {
    content: '';
    position: absolute;
    inset: 1px;
    z-index: -1;
    background: var(--fill);
    clip-path: polygon(0 0, calc(100% - var(--cut) + 0.6px) 0, 100% calc(var(--cut) - 0.6px), 100% 100%, 0 100%);
}

.cut:focus-visible { outline: none; --border: var(--accent); }

/* ── Texto ─────────────────────────────────────────────────────────────── */
.overline {
    font-family: var(--mono);
    font-size: 0.6875rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--dim);
}

.num { font-family: var(--mono); }

.help {
    margin: 0;
    font-size: 0.875rem;
    color: var(--dim);
    overflow-wrap: anywhere;
}

/* Cuadradito de señal + texto (estados) */
.sq {
    --sq: var(--dim);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.sq::before {
    content: '';
    flex: none;
    width: 0.5rem;
    height: 0.5rem;
    background: var(--sq);
}

.sq--info { --sq: var(--info); }
.sq--success { --sq: var(--success); }
.sq--warning { --sq: var(--warning); }
.sq--danger { --sq: var(--danger); }

/* ── Marca ─────────────────────────────────────────────────────────────── */
.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.brand-mark {
    --fill: var(--surface-2);
    display: grid;
    place-items: center;
    flex: none;
    width: var(--touch);
    height: var(--touch);
    color: var(--text);
}

.brand-mark svg { width: 1.25rem; height: 1.25rem; }

.brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.brand-name {
    margin: 0;
    overflow: hidden;
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.04em;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* ── Entrar ────────────────────────────────────────────────────────────── */
.login {
    display: grid;
    place-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1.5rem var(--page-pad) calc(1.5rem + env(safe-area-inset-bottom));
}

.login-card {
    width: min(26rem, 100%);
    gap: 1.5rem;
    padding: 1.5rem;
}

.login-card .brand-name {
    font-size: 1.5rem;
    white-space: normal;
}

/* ── Barra de arriba ───────────────────────────────────────────────────── */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding-top: max(0.625rem, env(safe-area-inset-top));
    padding-bottom: 0.625rem;
    padding-left: max(var(--page-pad), env(safe-area-inset-left), calc((100% - var(--page-max)) / 2 + var(--page-pad)));
    padding-right: max(var(--page-pad), env(safe-area-inset-right), calc((100% - var(--page-max)) / 2 + var(--page-pad)));
    background: var(--ground);
    border-bottom: 1px solid var(--line);
}

.topbar-right {
    display: flex;
    flex: none;
    align-items: center;
    gap: 0.5rem;
}

.sync {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 0.25rem;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--dim);
    white-space: nowrap;
}

@media (max-width: 30rem) {
    .topbar .brand-mark { display: none; }
    .sync-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
    }
}

/* ── Contenido ─────────────────────────────────────────────────────────── */
.content {
    display: grid;
    gap: 1.5rem;
    max-width: var(--page-max);
    margin: 0 auto;
    padding-top: 1rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    padding-left: max(var(--page-pad), env(safe-area-inset-left));
    padding-right: max(var(--page-pad), env(safe-area-inset-right));
}

.col {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
}

@media (min-width: 60rem) {
    .content {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: start;
        padding-top: 1.5rem;
    }
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 1.5rem;
    margin-bottom: 0.625rem;
}

.section-title {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text);
}

.count {
    font-size: 0.8125rem;
    color: var(--dim);
}

/* ── Paneles y tarjetas ────────────────────────────────────────────────── */
.panel,
.card,
.dialog {
    --cut: var(--notch-panel);
}

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

.empty { gap: 0.25rem; }

.empty-title {
    margin: 0;
    font-weight: 700;
}

.list {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.list + .help,
.list + .btn { margin-top: 0.625rem; }

.card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
}

.card-head {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.card-pos {
    flex: none;
    min-width: 1.5rem;
    padding-top: 0.125rem;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--dim);
}

.card-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.card--current .card-title { font-size: 1.25rem; }

/* El botón de ver más no agranda la cabecera (y no pisa el corte de la esquina) */
.card-toggle { margin: -0.5rem -0.5rem -0.5rem 0; }
.card-toggle svg { transition: transform 0.3s ease; }
.card-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

.card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.875rem;
    font-family: var(--mono);
    font-size: 0.75rem;
    color: var(--dim);
}

.card-meta .state {
    font-family: var(--font);
    font-size: 0.8125rem;
    color: var(--text);
}

.tag {
    font-family: var(--font);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--text);
}

.block {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.block-label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--dim);
}

.card-text {
    margin: 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.is-clamped {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    line-clamp: 4;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--line);
}

.grow { flex: 1 1 0; }

/* Historial y notas */
.last-note {
    --cut: var(--notch-control);
    --fill: var(--surface-2);
    --border: var(--line);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.625rem 0.75rem;
}

.events {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0;
    padding: 0.75rem 0 0;
    list-style: none;
    border-top: 1px solid var(--line);
}

.event {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.event-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 0.5rem;
    font-size: 0.8125rem;
    color: var(--dim);
}

.event-who {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text);
}

.event-head time {
    font-family: var(--mono);
    font-size: 0.75rem;
}

.event-text {
    margin: 0;
    font-size: 0.875rem;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* ── Botones ───────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: var(--touch);
    padding: 0 1.125rem;
    border: 0;
    border-radius: 0;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0.14em;
    text-align: center;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
}

.btn svg { width: 1rem; height: 1rem; }

/* Principal: la acción importante de la pantalla (una por pantalla) */
.btn--primary { --border: var(--accent); --fill: var(--accent); color: var(--ink); }
.btn--primary:focus-visible { --border: var(--text); }

/* Peligro: lo que no se puede deshacer */
.btn--danger { --border: var(--danger); }

.btn--ghost {
    align-self: flex-start;
    padding: 0 0.5rem;
    background: transparent;
    color: var(--dim);
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: var(--touch);
    height: var(--touch);
    padding: 0;
    border: 0;
    border-radius: 0;
    color: var(--dim);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
}

.icon-btn svg { width: 1.125rem; height: 1.125rem; }
.icon-btn--ghost { background: transparent; }
.icon-btn:focus-visible { color: var(--text); }
.icon-btn--ghost:focus-visible { outline-offset: -4px; }

.btn:active,
.icon-btn:active { transform: translateY(1px); }

.btn:disabled,
.icon-btn:disabled {
    opacity: 0.4;
    pointer-events: none;
}

@media (hover: hover) {
    .btn:hover { --fill: var(--surface-2); }
    .btn--primary:hover { --border: var(--accent-hover); --fill: var(--accent-hover); }
    .btn--danger:hover { --fill: var(--danger-fill); }
    .btn--ghost:hover { color: var(--text); }
    .icon-btn:hover { --fill: var(--surface-2); color: var(--text); }
    .icon-btn--danger:hover { --border: var(--danger); --fill: var(--danger-fill); }
}

/* ── Formularios ───────────────────────────────────────────────────────── */
.stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.label {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--dim);
}

.label-note {
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: none;
}

.field {
    --cut: var(--notch-field);
    --fill: var(--surface-2);
    display: block;
}

.field:focus-within { --border: var(--accent); }

.field input,
.field textarea {
    display: block;
    width: 100%;
    min-height: var(--touch);
    margin: 0;
    padding: 0 0.75rem;
    border: 0;
    border-radius: 0;
    outline: none;
    background: transparent;
    color: var(--text);
    font: 500 1rem/1.4 var(--font);
    letter-spacing: 0;
    text-transform: none;
    -webkit-appearance: none;
    appearance: none;
}

.field textarea {
    min-height: 7rem;
    padding: 0.625rem 0.75rem;
    resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
    color: var(--dim);
    opacity: 1;
}

/* El autorrelleno del navegador no puede pintar el campo de azul claro */
.field input:-webkit-autofill {
    -webkit-text-fill-color: var(--text);
    caret-color: var(--text);
    -webkit-box-shadow: 0 0 0 100rem var(--surface-2) inset;
    box-shadow: 0 0 0 100rem var(--surface-2) inset;
}

.check {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-height: var(--touch);
    cursor: pointer;
}

.check input {
    display: grid;
    place-content: center;
    flex: none;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    border: 1px solid var(--edge);
    border-radius: 0;
    background: var(--surface-2);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

.check input::before {
    content: '';
    width: 0.75rem;
    height: 0.75rem;
    background: var(--ink);
    clip-path: polygon(14% 44%, 0 59%, 40% 100%, 100% 23%, 86% 9%, 39% 70%);
    transform: scale(0);
}

.check input:checked { border-color: var(--accent); background: var(--accent); }
.check input:checked::before { transform: scale(1); }

.form-error {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.875rem;
    color: var(--text);
}

.form-error::before {
    content: '';
    flex: none;
    width: 0.5rem;
    height: 0.5rem;
    margin-top: 0.4em;
    background: var(--danger);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.625rem;
}

.actions .btn { flex: 1 1 8rem; }

/* ── Ventanas ──────────────────────────────────────────────────────────── */
.dialog {
    position: fixed;
    width: min(32rem, calc(100% - 2rem));
    max-width: none;
    max-height: calc(100% - 2rem);
    margin: auto;
    padding: 0;
    border: 0;
    color: var(--text);
    overflow: hidden;
    overflow: clip;
}

.dialog[open] {
    display: flex;
    flex-direction: column;
    animation: fade 0.3s ease;
}

.dialog::backdrop { background: var(--backdrop); }

.dialog > form {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1.25rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--edge) transparent;
}

/* ── Avisos ────────────────────────────────────────────────────────────── */
.toast {
    --fill: var(--surface-2);
    position: fixed;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    left: 50%;
    z-index: 50;
    width: max-content;
    max-width: calc(100% - 2rem);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    transform: translateX(-50%);
    animation: fade 0.3s ease;
}

.toast--error { --border: var(--danger); }

@keyframes fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}
