/* Sistema de diseño de AgroRuta para las pantallas del Dueño y del Operador (computadora). */

@font-face {
    font-family: "Jakarta";
    src: url("/fonts/fuente.woff2") format("woff2");
    font-weight: 400 800;
    font-style: normal;
    font-display: swap;
}

:root {
    --verde: #1E7F4B;
    --verde-hover: #17653C;
    --verde-oscuro: #0F3D2E;
    --verde-claro: #E3F2E8;
    --fondo: #F2F5F0;
    --tarjeta: #FFFFFF;
    --borde: #DCE5DE;
    --texto: #14201A;
    --texto-suave: #5B6B61;
    --amarillo: #F2B705;
    --amarillo-claro: #FFF4CC;
    --terracota: #C8642B;
    --terracota-texto: #A8501F;
    --terracota-claro: #FBE9DD;
    --error: #C73B3B;
    --error-claro: #FBE6E6;
    --foco: #0F3D2E;
    --radio: 20px;
    --radio-chico: 12px;
    --sombra: 0 1px 2px rgba(15, 61, 46, 0.06), 0 8px 24px rgba(15, 61, 46, 0.05);
}

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

html {
    font-size: 16px;
}

body {
    margin: 0;
    background: var(--fondo);
    color: var(--texto);
    font-family: "Jakarta", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p {
    margin: 0;
}

h1 {
    font-size: 1.75rem;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 1.25rem;
    line-height: 1.3;
    font-weight: 700;
    letter-spacing: -0.01em;
}

a {
    color: var(--verde);
    text-underline-offset: 3px;
}

.suave {
    color: var(--texto-suave);
    font-size: 0.875rem;
}

.oculto {
    display: none !important;
}

.solo-lectores {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Foco siempre visible: borde de 2 px con buen contraste. */
:focus-visible {
    outline: 2px solid var(--foco);
    outline-offset: 2px;
}

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

.boton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 22px;
    border: 2px solid var(--verde);
    border-radius: var(--radio-chico);
    background: var(--verde);
    color: #FFFFFF;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s, border-color 0.15s;
}

.boton:hover {
    background: var(--verde-hover);
    border-color: var(--verde-hover);
}

.boton[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.boton-secundario {
    background: transparent;
    color: var(--verde-oscuro);
    border-color: var(--borde);
}

.boton-secundario:hover {
    background: var(--verde-claro);
    border-color: var(--verde);
}

.boton-ancho {
    width: 100%;
}

/* ---------- Campos de formulario ---------- */

.campo {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
}

.campo__etiqueta {
    font-size: 0.875rem;
    font-weight: 600;
}

.campo__control {
    position: relative;
}

.campo__entrada {
    width: 100%;
    min-height: 48px;
    padding: 0 14px;
    border: 1.5px solid #7A897F;
    border-radius: var(--radio-chico);
    background: #FFFFFF;
    color: var(--texto);
    font: inherit;
}

.campo__entrada::placeholder {
    color: #667569;
}

.campo__entrada:focus {
    outline: none;
    border: 2px solid var(--foco);
    padding: 0 13.5px;
}

.campo--error .campo__entrada {
    border-color: var(--error);
}

.campo--error .campo__entrada:focus {
    border-color: var(--error);
}

.campo__ayuda {
    font-size: 0.8125rem;
    color: var(--texto-suave);
}

.campo__error {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--error);
}

.campo__ojo {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    min-width: 40px;
    min-height: 40px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--texto-suave);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
}

.campo__ojo:hover {
    color: var(--texto);
}

/* ---------- Tarjetas, avisos, tablas ---------- */

.tarjeta {
    background: var(--tarjeta);
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    padding: 24px;
}

.tarjeta__titulo {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--texto-suave);
}

.aviso {
    padding: 12px 16px;
    border-radius: var(--radio-chico);
    background: var(--verde-claro);
    border-left: 4px solid var(--verde);
    font-size: 0.9375rem;
}

.aviso--error {
    background: var(--error-claro);
    border-left-color: var(--error);
    color: #7A1F1F;
}

.aviso--atencion {
    background: var(--amarillo-claro);
    border-left-color: var(--amarillo);
}

.cifra {
    font-size: clamp(1.5rem, 2vw, 2.25rem);
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.cifra--mediana {
    font-size: 1.75rem;
}

.etiqueta-estado {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--verde-claro);
    color: var(--verde-oscuro);
    font-size: 0.8125rem;
    font-weight: 700;
}

.etiqueta-estado--espera {
    background: var(--amarillo-claro);
    color: #5C4500;
}

.tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.tabla th {
    text-align: left;
    padding: 10px 12px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--texto-suave);
    border-bottom: 1px solid var(--borde);
}

.tabla td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--borde);
    font-variant-numeric: tabular-nums;
}

.tabla tr:last-child td {
    border-bottom: 0;
}

.vacio {
    padding: 28px 12px;
    text-align: center;
    color: var(--texto-suave);
}

.vacio strong {
    display: block;
    margin-bottom: 4px;
    color: var(--texto);
}

/* Esqueleto de carga: se ve el espacio que ocupará el contenido. */
.esqueleto {
    display: block;
    min-height: 1em;
    border-radius: 8px;
    background: linear-gradient(90deg, #E6ECE7 25%, #F3F6F3 50%, #E6ECE7 75%);
    background-size: 200% 100%;
    animation: brillo 1.4s ease-in-out infinite;
}

@keyframes brillo {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* ---------- Estructura con menú lateral ---------- */

.estructura {
    display: grid;
    grid-template-columns: 264px 1fr;
    min-height: 100vh;
}

.menu {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 20px 16px;
    background: var(--verde-oscuro);
    color: #D7E8DC;
}

.menu__marca {
    display: flex;
    justify-content: center;
    padding: 10px;
    border-radius: var(--radio);
    background: #FFFFFF;
}

.menu__marca img {
    display: block;
    width: 112px;
    height: 112px;
}

.menu__lista {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.menu__enlace {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 14px;
    border-radius: var(--radio-chico);
    color: #D7E8DC;
    font-weight: 600;
    text-decoration: none;
}

.menu__enlace:hover {
    background: rgba(255, 255, 255, 0.08);
}

.menu__enlace[aria-current="page"] {
    background: var(--verde);
    color: #FFFFFF;
}

.menu__enlace--pronto {
    color: #9DB8A8;
    cursor: default;
}

.menu__enlace--pronto:hover {
    background: transparent;
}

.menu__icono {
    flex: none;
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.menu__pronto {
    margin-left: auto;
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    font-size: 0.75rem;
    font-weight: 600;
}

.menu :focus-visible {
    outline-color: var(--amarillo);
}

.contenido {
    min-width: 0;
    padding: 28px 40px 48px;
}

.encabezado {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 28px;
}

.encabezado__sesion {
    display: flex;
    align-items: center;
    gap: 14px;
}

.encabezado__usuario {
    text-align: right;
    line-height: 1.3;
}

.encabezado__usuario strong {
    display: block;
}

.rejilla-cifras {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.rejilla-principal {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    gap: 20px;
}

/* ---------- Pantalla de entrada ---------- */

.entrada {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.entrada__lado {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    padding: 56px;
    background: var(--verde-oscuro);
    color: #FFFFFF;
}

.entrada__lado img {
    width: 140px;
    height: 140px;
    padding: 12px;
    border-radius: var(--radio);
    background: #FFFFFF;
}

.entrada__lado h1 {
    max-width: 14ch;
    font-size: 2.5rem;
}

.entrada__lado p {
    max-width: 38ch;
    color: #C5DDCD;
}

.entrada__formulario {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.entrada__caja {
    width: 100%;
    max-width: 400px;
}

.entrada__caja h2 {
    margin-bottom: 6px;
    font-size: 1.75rem;
}

.entrada__caja > p {
    margin-bottom: 24px;
}

/* ---------- Adaptación ---------- */

@media (max-width: 1100px) {
    .estructura {
        grid-template-columns: 76px 1fr;
    }

    .menu__marca img {
        width: 44px;
        height: 44px;
    }

    .menu__marca {
        padding: 6px;
    }

    .menu__texto,
    .menu__pronto {
        display: none;
    }

    .menu__enlace {
        justify-content: center;
        padding: 0;
    }

    .contenido {
        padding: 24px;
    }

    .rejilla-cifras,
    .rejilla-cifras--tres {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .rejilla-principal {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 700px) {
    .estructura {
        grid-template-columns: minmax(0, 1fr);
    }

    .menu {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        overflow-x: auto;
        gap: 12px;
        padding: 10px 12px;
    }

    .menu__lista {
        flex-direction: row;
    }

    .contenido {
        padding: 16px;
    }

    .rejilla-cifras,
    .rejilla-cifras--tres {
        grid-template-columns: minmax(0, 1fr);
    }

    .entrada {
        grid-template-columns: minmax(0, 1fr);
    }

    .entrada__lado {
        display: none;
    }
}

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

/* ---------- Panel de inicio ---------- */

.esqueleto--cifra {
    width: 60%;
    height: 2.5rem;
}

.tarjeta .cifra {
    margin: 10px 0 6px;
}

.tarjeta--atencion {
    border-left: 6px solid var(--amarillo);
}

.rejilla-cifras--tres {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.rejilla-principal--una {
    grid-template-columns: minmax(0, 1fr);
}

.tendencia--sube {
    color: var(--verde-hover);
    font-weight: 700;
}

.tendencia--baja {
    color: var(--terracota-texto);
    font-weight: 700;
}

.dato-perdida {
    color: var(--terracota-texto);
    font-weight: 700;
}

.grafico {
    margin-top: 12px;
}

.grafico svg {
    display: block;
    width: 100%;
    height: auto;
}

.grafico text {
    font-family: inherit;
    font-size: 13px;
    fill: var(--texto-suave);
}

.grafico .grafico__valor {
    font-weight: 700;
    fill: var(--texto);
}

.grafico .grafico__eje {
    stroke: var(--borde);
    stroke-width: 1;
}

.grafico .barra {
    fill: var(--verde-claro);
    stroke: var(--verde);
    stroke-width: 1.5;
}

.grafico .barra--actual {
    fill: var(--verde);
}

#error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

#error.oculto {
    display: none;
}

/* ---------- Pantallas internas: barra, tablas, panel lateral, avisos, pestañas ---------- */

.barra {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.barra__texto {
    max-width: 70ch;
}

.tabla-envoltorio {
    overflow-x: auto;
}

.fila--destacada td {
    background: var(--verde-claro);
    font-weight: 600;
}

.fila-acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fila-acciones .boton {
    min-height: 36px;
    padding: 0 14px;
    font-size: 0.875rem;
}

.etiqueta-estado--error {
    background: var(--error-claro);
    color: #7A1F1F;
}

.etiqueta-estado--neutro {
    background: #E9EEEA;
    color: var(--texto);
}

.fondo-panel {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    justify-content: flex-end;
    background: rgba(15, 61, 46, 0.45);
}

.panel {
    display: flex;
    flex-direction: column;
    width: 440px;
    max-width: 100vw;
    height: 100%;
    background: #FFFFFF;
    box-shadow: -12px 0 32px rgba(15, 61, 46, 0.2);
    animation: entrar-panel 0.18s ease-out;
}

.panel--ancho {
    width: 680px;
}

@keyframes entrar-panel {
    from { transform: translateX(32px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

.panel__cabecera {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--borde);
}

.panel__cuerpo {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 4px;
    padding: 24px;
    overflow-y: auto;
}

.panel__texto {
    margin-bottom: 14px;
}

.panel__nota {
    min-height: 1.5em;
    font-weight: 600;
    color: var(--verde-oscuro);
}

.panel__pie {
    position: sticky;
    bottom: -24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin: auto -24px -24px;
    padding: 16px 24px;
    border-top: 1px solid var(--borde);
    background: #FFFFFF;
}

.avisos {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    max-width: 380px;
    padding: 12px 18px;
    border-radius: var(--radio-chico);
    background: var(--verde-oscuro);
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: var(--sombra);
}

.toast--error {
    background: #7A1F1F;
}

.pestanas {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--borde);
}

.pestana {
    min-height: 44px;
    padding: 0 20px;
    border: 0;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    background: transparent;
    color: var(--texto-suave);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.pestana[aria-selected="true"] {
    color: var(--verde-oscuro);
    border-bottom-color: var(--verde);
}

.filtros {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.filtro {
    min-height: 36px;
    padding: 0 14px;
    border: 1.5px solid var(--borde);
    border-radius: 999px;
    background: #FFFFFF;
    color: var(--texto);
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}

.filtro[aria-pressed="true"] {
    border-color: var(--verde);
    background: var(--verde-claro);
    color: var(--verde-oscuro);
}

.bloque {
    margin-bottom: 24px;
}

.bloque h3 {
    margin-bottom: 8px;
    font-size: 1rem;
}

.linea-tiempo {
    margin: 0;
    padding-left: 18px;
    border-left: 2px solid var(--borde);
    list-style: none;
}

.linea-tiempo li {
    margin-bottom: 12px;
}

.enlace-copiable {
    display: flex;
    gap: 8px;
    align-items: center;
}

.enlace-copiable input {
    flex: 1;
    min-width: 0;
}

.mapa {
    height: 320px;
    border-radius: var(--radio-chico);
    border: 1px solid var(--borde);
}

@media (prefers-reduced-motion: reduce) {
    .panel {
        animation: none;
    }
}

@media (max-width: 700px) {
    .panel,
    .panel--ancho {
        width: 100vw;
    }
}

/* ---------- Mapa de envíos ---------- */

.marcador-vehiculo {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--verde);
    border: 3px solid #FFFFFF;
    box-shadow: 0 0 0 2px var(--verde-oscuro);
}

.marcador-destino {
    width: 16px;
    height: 16px;
    background: var(--terracota);
    border: 3px solid #FFFFFF;
    box-shadow: 0 0 0 2px var(--terracota-texto);
    transform: rotate(45deg);
}

.cifras-liquidacion {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 12px 0;
}

.cifras-liquidacion .tarjeta {
    padding: 14px 16px;
}

.cifras-liquidacion .cifra {
    font-size: 1.25rem;
    margin-top: 4px;
}

/* Las tablas no parten placas, cifras ni estados; solo las columnas de texto largo pueden pasar a otra línea. */
.tabla td,
.tabla th {
    white-space: nowrap;
}

.tabla td.largo,
.tabla th.largo {
    white-space: normal;
    min-width: 160px;
}

/* ---------- Código QR ---------- */

.codigo-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 0 0 24px;
    padding: 16px;
    border: 1px solid var(--borde);
    border-radius: var(--radio-chico);
    background: #FFFFFF;
}

.codigo-qr img {
    width: 220px;
    height: 220px;
    image-rendering: pixelated;
}

.codigo-qr figcaption {
    max-width: 36ch;
    text-align: center;
}

/* ---------- Reportes ---------- */

.filtros-detalle {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 8px;
}

.filtros-detalle label {
    display: grid;
    gap: 4px;
    font-size: 0.875rem;
    font-weight: 600;
}

.filtros-detalle__rango {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.filtros-detalle__rango.oculto {
    display: none;
}

.veredicto {
    padding: 20px 24px;
    border: 1.5px solid var(--borde);
    border-left-width: 8px;
    border-radius: var(--radio);
    background: var(--tarjeta);
}

.veredicto__titulo {
    display: block;
    font-size: 1.375rem;
}

.veredicto__texto {
    margin: 6px 0 0;
}

.veredicto--ganando {
    border-color: var(--verde);
    background: var(--verde-claro);
}

.veredicto--menos {
    border-color: var(--amarillo);
    background: var(--amarillo-claro);
}

.veredicto--perdiendo {
    border-color: var(--error);
    background: var(--error-claro);
}

.causas {
    margin: 0;
    padding: 0;
    list-style: none;
}

.causas__fila {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--borde);
}

.causas__fila span:first-child {
    min-width: 12rem;
    font-weight: 600;
}

.grafico .barra--perdida {
    fill: var(--error-claro);
    stroke: var(--error);
}
