/* ConsultaPAX - interfaz funcionarios */
:root {
    --brand: #29235c;
    --brand-dark: #1b1740;
    --brand-light: #3b3380;
    --brand-soft: #ebeaf5;
    --accent: #e30613;
    --accent-dark: #bf0510;
    --accent-soft: #fde8ea;
    --bg: #f3f6fa;
    --surface: #ffffff;
    --text: #1b2733;
    --muted: #6b7a8c;
    --line: #e2e8f0;
    --ok: #12805c;
    --ok-bg: #dff5ec;
    --warn: #9a6700;
    --warn-bg: #fff4d6;
    --neutral: #475569;
    --neutral-bg: #e8edf3;
    --danger: #b42318;
    --danger-bg: #fde8e6;
    --radius: 16px;
    --shadow: 0 1px 2px rgba(15, 35, 60, .06), 0 8px 24px rgba(15, 35, 60, .08);
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.icon { width: 1.1em; height: 1.1em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Cabecera ---------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 1000;
}
.topbar__inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.topbar__logo { height: 52px; width: auto; display: block; }
.topbar__brand { font-size: 1.35rem; font-weight: 800; letter-spacing: .12em; color: var(--brand); }
.topbar__tag {
    font-size: .8rem;
    font-weight: 600;
    color: var(--brand);
    background: var(--brand-soft);
    padding: 6px 12px;
    border-radius: 999px;
    letter-spacing: .02em;
    white-space: nowrap;
}

/* ---------- Layout ---------- */
.wrap { max-width: 960px; margin: 0 auto; padding: 0 20px; }

.hero {
    background: linear-gradient(135deg, var(--brand-dark) 0%, var(--brand) 55%, var(--brand-light) 100%);
    border-bottom: 4px solid var(--accent);
    color: #fff;
    padding: 44px 0 88px;
}
.hero h1 { margin: 0 0 8px; font-size: clamp(1.6rem, 4.5vw, 2.3rem); line-height: 1.2; font-weight: 700; }
.hero p { margin: 0; color: rgba(255, 255, 255, .8); max-width: 560px; }

.panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.search { margin-top: -56px; }
.search label { display: block; font-weight: 600; margin-bottom: 8px; }
.search__row { display: flex; gap: 12px; }
.search__field {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1.5px solid var(--line);
    border-radius: 12px;
    padding: 0 14px;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.search__field:focus-within { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.search__field .icon { color: var(--muted); }
.search__field input {
    border: 0;
    outline: 0;
    flex: 1;
    min-width: 0;
    font-size: 1.1rem;
    padding: 14px 0;
    background: transparent;
    color: var(--text);
    font-family: inherit;
}
.search__hint { margin: 10px 0 0; color: var(--muted); font-size: .85rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    font: inherit;
    font-weight: 600;
    padding: 14px 22px;
    cursor: pointer;
    text-decoration: none;
    transition: transform .1s, background .15s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); }
.btn--ghost { background: var(--brand-soft); color: var(--brand); }
.btn--ghost:hover { background: #dedcee; }
.btn--block { width: 100%; }
.btn:focus-visible { outline: 3px solid var(--brand-light); outline-offset: 2px; }
.search__field input:focus-visible { outline: none; }

.notice {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: var(--warn-bg);
    color: var(--warn);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 20px;
    font-size: .92rem;
}
.notice strong { display: block; }
.notice--error { background: var(--danger-bg); color: var(--danger); }
.notice--info { background: var(--brand-soft); color: var(--brand); }

/* ---------- Resultados ---------- */
.results { padding-top: 32px; padding-bottom: 48px; }
.results__title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 16px; }
.results__title h2 { margin: 0; font-size: 1.15rem; }
.results__title span { color: var(--muted); font-size: .9rem; }

.ruta {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
    overflow: hidden;
    border-left: 5px solid var(--neutral-bg);
}
.ruta--activa { border-left-color: var(--brand); }

.ruta__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}
.ruta__when { display: flex; flex-direction: column; }
.ruta__date { font-weight: 700; font-size: 1.05rem; }
.ruta__time { color: var(--muted); font-size: .88rem; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: .8rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--neutral-bg);
    color: var(--neutral);
}
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge__dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge--ok .badge__dot { animation: pulso 1.6s infinite; }
@keyframes pulso { 0% { box-shadow: 0 0 0 0 rgba(18, 128, 92, .5); } 100% { box-shadow: 0 0 0 8px rgba(18, 128, 92, 0); } }

.ruta__body { padding: 18px 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; }
.dato { display: flex; gap: 12px; min-width: 0; }
.dato .icon { color: var(--brand-light); margin-top: 3px; width: 1.25em; height: 1.25em; }
.dato__label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.dato__value { font-weight: 600; overflow-wrap: anywhere; }
.dato--full { grid-column: 1 / -1; }

.ruta__foot { padding: 0 20px 20px; }

.vacio { text-align: center; padding: 40px 24px; }
.vacio .icon { width: 2.6em; height: 2.6em; color: var(--muted); margin-bottom: 8px; }
.vacio h3 { margin: 0 0 6px; }
.vacio p { margin: 0; color: var(--muted); }

.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 24px 20px 32px; }

/* ---------- Mapa ---------- */
body.page-map { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.mapview { position: relative; flex: 1; min-height: 0; }
#map { position: absolute; inset: 0; z-index: 1; }

.mapcard {
    position: absolute;
    z-index: 500;
    top: 16px;
    left: 16px;
    width: 340px;
    max-height: calc(100% - 32px);
    overflow: auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
}
.mapcard__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.mapcard h1 { font-size: 1.05rem; margin: 0 0 2px; overflow-wrap: anywhere; }
.mapcard__sub { color: var(--muted); font-size: .85rem; margin-bottom: 14px; }
.mapcard .dato { margin-bottom: 12px; }
.mapcard .btn { margin-top: 6px; padding: 11px 16px; }

.live { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); margin: 4px 0 8px; }
.live__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.live--ok .live__dot { background: var(--ok); animation: pulso 1.6s infinite; }
.live--err .live__dot { background: var(--danger); }

.marker-movil {
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent); border: 3px solid #fff;
    box-shadow: 0 0 0 0 rgba(227, 6, 19, .6), 0 2px 6px rgba(0, 0, 0, .35);
    animation: pulso-mapa 1.8s infinite;
}
@keyframes pulso-mapa { 0% { box-shadow: 0 0 0 0 rgba(227, 6, 19, .6), 0 2px 6px rgba(0,0,0,.35); } 100% { box-shadow: 0 0 0 16px rgba(227, 6, 19, 0), 0 2px 6px rgba(0,0,0,.35); } }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
    .topbar__tag { display: none; }
    .search__row { flex-direction: column; }
    .ruta__body { grid-template-columns: 1fr; }
    .panel { padding: 18px; }
    .mapcard {
        top: auto; bottom: 0; left: 0; right: 0;
        width: auto; max-height: 48%;
        border-radius: var(--radius) var(--radius) 0 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .badge--ok .badge__dot, .marker-movil, .live--ok .live__dot { animation: none; }
}
