/* Mis Vehículos (web). Los colores son los de la app de Android: azul #1565C0, naranja #FF6F00 y los de cada estado. */

:root {
    --primary: #1565c0;
    --primary-hover: #0d4f9e;
    --primary-soft: #e3eefb;
    --on-primary: #ffffff;
    --accent: #ff6f00;
    --accent-hover: #e66300;
    --on-accent: #1a1100;

    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #eef1f6;
    --text: #1b1f27;
    --text-muted: #5b6474;
    --border: #dde2ea;
    --field: #fafbfd;
    --shadow: 0 1px 2px rgb(16 24 40 / 0.06), 0 2px 8px rgb(16 24 40 / 0.06);

    /* Estados (los mismos de la app) */
    --overdue: #c62828;
    --soon: #f57c00;
    --soon-text: #b45309;
    --ok: #2e7d32;
    --check: #5c6bc0;
    --pending: #546e7a;
    --danger: var(--overdue);

    --radius: 12px;
    --radius-sm: 10px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary: #5aa2f0;
        --primary-hover: #7bb5f4;
        --primary-soft: #16263d;
        --on-primary: #08121f;
        --accent: #ff8a2a;
        --accent-hover: #ff9d4d;
        --bg: #0f1218;
        --surface: #181c24;
        --surface-2: #222833;
        --text: #e8ebf1;
        --text-muted: #9aa3b2;
        --border: #2c3340;
        --field: #12161d;
        --shadow: 0 1px 2px rgb(0 0 0 / 0.4);
        --overdue: #ef5350;
        --soon: #ffa040;
        --soon-text: #ffb366;
        --ok: #66bb6a;
        --check: #8c9eff;
        --pending: #90a4ae;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.45; color: var(--text); background: var(--bg); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
/* Blazor enfoca el título al navegar (para lectores de pantalla): sin recuadro, que no es un control. */
h1[tabindex="-1"]:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Carga inicial ---------- */
.boot { display: grid; place-items: center; align-content: center; gap: 1rem; min-height: 100vh; color: var(--text-muted); }
.boot img { border-radius: 18px; }
.boot-bar { width: 160px; height: 4px; overflow: hidden; background: var(--border); border-radius: 4px; }
.boot-bar span { display: block; height: 100%; width: var(--blazor-load-percentage, 10%); background: var(--primary); transition: width 0.2s; }
#blazor-error-ui { display: none; position: fixed; inset: auto 0 0 0; z-index: 100; padding: 0.8rem 1rem; color: #fff; background: var(--overdue); }
#blazor-error-ui a { color: #fff; margin-left: 0.5rem; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ---------- Estructura ---------- */
.app { min-height: 100vh; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 20; color: var(--on-primary); background: var(--primary); box-shadow: 0 1px 0 rgb(0 0 0 / 0.08); }
.topbar-inner { display: flex; align-items: center; gap: 0.5rem; max-width: 820px; min-height: 58px; margin: 0 auto; padding: 0 0.5rem; }
.topbar h1 { flex: 1; min-width: 0; overflow: hidden; font-size: 1.2rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.topbar .sub { display: block; font-size: 0.8rem; font-weight: 500; opacity: 0.85; }
.topbar .icon-btn { color: inherit; }
.topbar .icon-btn:hover { background: rgb(255 255 255 / 0.14); }
.content { max-width: 820px; margin: 0 auto; padding: 1rem; }
.content.narrow { max-width: 560px; }

.tabbar { position: fixed; inset: auto 0 0 0; z-index: 20; display: flex; justify-content: center; padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border); }
.tabbar a { flex: 1; max-width: 220px; display: grid; justify-items: center; gap: 2px; padding: 0.55rem 0 0.6rem; font-size: 0.78rem; font-weight: 600;
    color: var(--text-muted); text-decoration: none; }
.tabbar a .icon { font-size: 1.45rem; }
.tabbar a.active { color: var(--primary); }

/* ---------- Ingreso ---------- */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem 1rem; background: linear-gradient(160deg, var(--primary) 0%, var(--primary) 38%, var(--bg) 38%); }
.auth-card { width: 100%; max-width: 420px; padding: 1.75rem 1.5rem; background: var(--surface); border-radius: 18px; box-shadow: 0 12px 40px rgb(16 24 40 / 0.18); }
.auth-brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; }
.auth-brand img { border-radius: 14px; }
.auth-brand strong { display: block; font-size: 1.35rem; }
.auth-brand span { color: var(--text-muted); font-size: 0.92rem; }
.auth-switch { margin: 1.25rem 0 0; text-align: center; color: var(--text-muted); }

/* ---------- Botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; min-height: 44px; padding: 0.55rem 1.1rem; font-weight: 650;
    text-decoration: none; border: 1.5px solid transparent; border-radius: var(--radius-sm); cursor: pointer; background: transparent; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { color: var(--on-primary); background: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-accent { color: var(--on-accent); background: var(--accent); }
.btn-accent:hover:not(:disabled) { background: var(--accent-hover); }
.btn-outline { color: var(--primary); border-color: currentColor; }
.btn-outline:hover:not(:disabled) { background: var(--primary-soft); }
.btn-text { color: var(--primary); padding-inline: 0.6rem; }
.btn-text:hover:not(:disabled) { background: var(--primary-soft); }
.btn-danger { color: #fff; background: var(--danger); }
.btn-danger-text { color: var(--danger); padding-inline: 0.6rem; }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0.3rem 0.75rem; font-size: 0.9rem; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; font-size: 1.3rem; color: var(--text-muted);
    background: transparent; border: 0; border-radius: 50%; cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); }
.fab { position: fixed; right: max(1rem, calc(50% - 410px + 1rem)); bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 15;
    display: inline-flex; align-items: center; gap: 0.5rem; min-height: 54px; padding: 0 1.3rem; font-weight: 700; color: var(--on-accent);
    background: var(--accent); border: 0; border-radius: 18px; box-shadow: 0 6px 18px rgb(255 111 0 / 0.35); cursor: pointer; text-decoration: none; }
.fab:hover { background: var(--accent-hover); }
.fab .icon { font-size: 1.4rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: flex-end; margin-top: 1.25rem; }
.actions .spacer { flex: 1; }

/* ---------- Formularios ---------- */
.field { display: grid; gap: 0.3rem; margin-bottom: 1rem; }
.field > label, .label { font-size: 0.88rem; font-weight: 650; color: var(--text-muted); }
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
    width: 100%; min-height: 46px; padding: 0.65rem 0.85rem; background: var(--field); border: 1.5px solid var(--border); border-radius: var(--radius-sm); }
.field textarea { min-height: auto; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input-affix { display: flex; align-items: stretch; }
.input-affix input { border-radius: var(--radius-sm) 0 0 var(--radius-sm) !important; }
.input-affix .affix { display: grid; place-items: center; padding: 0 0.8rem; color: var(--text-muted); background: var(--surface-2);
    border: 1.5px solid var(--border); border-left: 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-affix.prefix input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0 !important; }
.input-affix.prefix .affix { border: 1.5px solid var(--border); border-right: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.hint { font-size: 0.85rem; color: var(--text-muted); }
.validation-message, .error-text { font-size: 0.85rem; color: var(--danger); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.75rem; }
.switch-row { display: flex; align-items: center; gap: 0.9rem; padding: 0.4rem 0; cursor: pointer; }
.switch-row > div { flex: 1; }
.switch-row strong { display: block; }
.switch { appearance: none; flex: none; position: relative; width: 46px; height: 28px; margin: 0; background: var(--border); border-radius: 999px; cursor: pointer; transition: background 0.15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgb(0 0 0 / 0.3); transition: transform 0.15s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(18px); }
.check-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0.25rem; border-bottom: 1px solid var(--border); cursor: pointer; }
.check-row:last-child { border-bottom: 0; }
.check-row input { width: 20px; height: 20px; accent-color: var(--primary); }
.check-row .emoji { font-size: 1.3rem; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; background: var(--surface-2); border-radius: var(--radius-sm); }
.segmented button { min-height: 38px; padding: 0.3rem 0.4rem; font-size: 0.9rem; font-weight: 600; color: var(--text-muted); background: transparent; border: 0; border-radius: 8px; cursor: pointer; }
.segmented button[aria-pressed=true] { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.type-option { display: flex; align-items: center; gap: 0.6rem; min-height: 56px; padding: 0.6rem 0.8rem; text-align: left; font-weight: 600;
    background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; }
.type-option .emoji { font-size: 1.7rem; }
.type-option[aria-pressed=true] { background: var(--primary-soft); border: 2px solid var(--primary); }

/* ---------- Tarjetas y listas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 0.7rem; }
.card-pad { padding: 1rem; }
.card-row { display: flex; align-items: center; gap: 0.85rem; padding: 0.85rem 0.5rem 0.85rem 0.9rem; }
.card-row > .grow { flex: 1; min-width: 0; }
a.card-row, button.card-row { width: 100%; color: inherit; text-align: left; text-decoration: none; background: none; border: 0; cursor: pointer; }
.tile { display: grid; place-items: center; flex: none; width: 52px; height: 52px; font-size: 1.7rem; background: var(--primary-soft); border-radius: 12px; }
.tile.sm { width: 42px; height: 42px; font-size: 1.35rem; border-radius: 10px; }
.title { font-weight: 700; }
.muted { color: var(--text-muted); }
.small { font-size: 0.88rem; }
.meta { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; margin-top: 0.2rem; font-size: 0.88rem; color: var(--text-muted); }
.section-title { margin: 1.4rem 0.25rem 0.55rem; font-size: 0.78rem; font-weight: 800; letter-spacing: 0.06em; color: var(--primary); text-transform: uppercase; }
.section-title:first-child { margin-top: 0.25rem; }
.list-card { overflow: hidden; }
.list-card > * + * { border-top: 1px solid var(--border); }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.6rem; font-size: 0.82rem; font-weight: 600; border-radius: 999px;
    background: var(--surface-2); color: var(--text-muted); }
.chip.blue { color: #1565c0; background: #e3f2fd; }
.chip.indigo { color: #3949ab; background: #e8eaf6; }
.chip.green { color: #2e7d32; background: #e8f5e9; }
.chip.orange { color: #b45309; background: #fff3e0; }
@media (prefers-color-scheme: dark) {
    .chip.blue { color: #90caf9; background: #102a43; }
    .chip.indigo { color: #9fa8da; background: #1c2040; }
    .chip.green { color: #a5d6a7; background: #13291a; }
    .chip.orange { color: #ffcc80; background: #33230f; }
}
.badges { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.badge { display: inline-block; padding: 0.1rem 0.5rem; font-size: 0.74rem; font-weight: 800; letter-spacing: 0.02em; border-radius: 999px; }

/* Estado de un mantenimiento: la pastilla y el color del texto */
.status { --c: var(--ok); display: inline-block; padding: 0.12rem 0.55rem; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.03em; color: var(--c);
    background: color-mix(in srgb, var(--c) 12%, transparent); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); border-radius: 999px; white-space: nowrap; }
.s-overdue { --c: var(--overdue); }
.s-soon { --c: var(--soon); }
.s-check { --c: var(--check); }
.s-pending { --c: var(--pending); }
.s-ok { --c: var(--ok); }
.c-text { color: var(--c); }
.s-soon .c-text, .s-soon.c-text { color: var(--soon-text); }
.tile.status-tile { background: color-mix(in srgb, var(--c) 14%, transparent); }

.rec { padding: 0.9rem 0.5rem 0.9rem 0.9rem; }
.rec-head { display: flex; align-items: flex-start; gap: 0.75rem; }
.rec-head .grow { flex: 1; min-width: 0; }
.rec-name { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; font-weight: 700; }
.rec-lines { display: grid; gap: 0.15rem; margin-top: 0.3rem; font-size: 0.9rem; }
.rec-lines .em { font-style: italic; }
.rec-appointment { margin-top: 0.5rem; padding: 0.4rem 0.6rem; font-size: 0.88rem; background: var(--primary-soft); border-radius: 8px; }
.rec-appointment.past { color: var(--overdue); background: color-mix(in srgb, var(--overdue) 10%, transparent); }

/* ---------- Detalle del vehículo ---------- */
.hero { color: var(--on-primary); background: var(--primary); }
.hero-inner { max-width: 820px; margin: 0 auto; padding: 0.2rem 1rem 1rem; }
.hero-line { display: flex; align-items: center; gap: 0.6rem; font-size: 1rem; }
.hero-line .emoji { font-size: 2rem; }
.hero .chips .chip { color: var(--on-primary); background: rgb(255 255 255 / 0.18); }
@media (prefers-color-scheme: dark) { .hero .chips .chip { background: rgb(0 0 0 / 0.18); } }
.tabs { position: sticky; top: 58px; z-index: 10; display: flex; background: var(--primary); }
.tabs-inner { display: flex; width: 100%; max-width: 820px; margin: 0 auto; }
.tabs button { flex: 1; min-height: 46px; font-weight: 700; color: rgb(255 255 255 / 0.75); background: transparent; border: 0; border-bottom: 3px solid transparent; cursor: pointer; }
@media (prefers-color-scheme: dark) { .tabs button { color: rgb(8 18 31 / 0.7); } }
.tabs button[aria-selected=true] { color: var(--on-primary); border-bottom-color: var(--accent); }
.banner { display: flex; align-items: center; gap: 0.75rem; width: 100%; margin-bottom: 0.75rem; padding: 0.85rem 1rem; text-align: left; color: inherit;
    border: 1px solid color-mix(in srgb, var(--c, var(--check)) 35%, transparent); border-radius: var(--radius);
    background: color-mix(in srgb, var(--c, var(--check)) 10%, var(--surface)); cursor: pointer; text-decoration: none; }
.banner .emoji { font-size: 1.5rem; }
.banner.info { --c: var(--primary); cursor: default; }

/* ---------- Menú (⋮), diálogos y avisos ---------- */
.menu { position: relative; }
.menu-list { position: absolute; right: 0.25rem; top: calc(100% - 4px); z-index: 30; min-width: 210px; padding: 0.35rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 10px 30px rgb(16 24 40 / 0.18); }
.menu-list button, .menu-list a { display: flex; align-items: center; gap: 0.6rem; width: 100%; min-height: 42px; padding: 0.45rem 0.75rem; color: var(--text);
    text-align: left; text-decoration: none; background: transparent; border: 0; border-radius: 8px; cursor: pointer; }
.menu-list button:hover, .menu-list a:hover { background: var(--surface-2); }
.menu-list .danger { color: var(--danger); }
.menu-backdrop { position: fixed; inset: 0; z-index: 25; background: transparent; border: 0; }
.topbar .menu-list { color: var(--text); }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: end center; padding: 0; background: rgb(10 14 22 / 0.5); }
.modal { width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; padding: 1.25rem 1.25rem calc(1rem + env(safe-area-inset-bottom));
    background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px rgb(0 0 0 / 0.25); }
.modal h2 { margin-bottom: 0.75rem; font-size: 1.2rem; }
.modal .actions { margin-top: 1rem; }
@media (min-width: 640px) {
    .modal-backdrop { place-items: center; padding: 1rem; }
    .modal { border-radius: 18px; padding-bottom: 1.25rem; }
}

.toasts { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 60; display: grid; gap: 0.5rem; width: min(92vw, 480px);
    transform: translateX(-50%); }
.toast { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; color: #fff; background: #263238; border-radius: 10px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.25); }
.toast.error { background: var(--overdue); }
.toast span { flex: 1; }
.toast button { color: inherit; background: none; border: 0; cursor: pointer; font-size: 1.1rem; }

.alert { display: flex; gap: 0.6rem; padding: 0.75rem 0.9rem; margin-bottom: 1rem; border-radius: var(--radius-sm); font-size: 0.93rem; }
.alert-error { color: var(--overdue); background: color-mix(in srgb, var(--overdue) 10%, transparent); }
.alert-info { color: var(--primary); background: var(--primary-soft); }
.alert-warn { color: var(--soon-text); background: color-mix(in srgb, var(--soon) 12%, transparent); }

.empty { display: grid; justify-items: center; gap: 0.75rem; padding: 3rem 1rem; text-align: center; color: var(--text-muted); white-space: pre-line; }
.empty .big { font-size: 3.2rem; opacity: 0.8; }
.loading { display: grid; place-items: center; padding: 3rem 1rem; color: var(--text-muted); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Ícono / emoji ---------- */
.emoji-field { display: flex; align-items: center; gap: 0.75rem; }
.emoji-field input { width: 76px !important; text-align: center; font-size: 1.6rem; }
.emoji-suggestions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; }
.emoji-suggestions button { width: 42px; height: 42px; font-size: 1.35rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; }
.emoji-suggestions button[aria-pressed=true] { border: 2px solid var(--primary); background: var(--primary-soft); }

.icon { display: inline-block; width: 1em; height: 1em; flex: none; vertical-align: -0.125em; }

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

/* ---------- Impresión (historial en PDF) ---------- */
.print-sheet { max-width: 900px; margin: 0 auto; padding: 1.5rem; background: #fff; color: #111; }
.print-sheet h1 { color: #1565c0; font-size: 1.5rem; }
.print-sheet table { width: 100%; margin-top: 1rem; border-collapse: collapse; font-size: 0.85rem; }
.print-sheet th { color: #fff; background: #1565c0; text-align: left; }
.print-sheet th, .print-sheet td { padding: 0.4rem 0.5rem; border-bottom: 1px solid #ddd; vertical-align: top; }
.print-sheet td.num { text-align: right; white-space: nowrap; }
@media print {
    .no-print, .topbar, .tabbar, .toasts { display: none !important; }
    .app { padding: 0; }
    body { background: #fff; }
    .print-sheet { padding: 0; }
    th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
