/*
 * TransDeca: shared look for every screen.
 * Loaded AFTER each page's own <style>, so these rules win at equal specificity.
 * Only appearance: no rule here may hide, move or disable a form control.
 * To brand another company (SaaS), change the tokens in :root.
 */
:root {
    --app-primario: #0876c9;
    --app-primario-oscuro: #06609f;
    --app-primario-suave: #eaf4fd;
    --app-exito: #1e8e4e;
    --app-exito-oscuro: #17723e;
    --app-peligro: #c62828;
    --app-peligro-oscuro: #a11f1f;
    --app-peligro-suave: #fdecec;
    --app-oscuro: #263746;
    --app-gris: #5b6b78;
    --app-gris-claro: #eef2f5;
    --app-borde: #cfd8df;
    --app-fondo: #f3f5f7;
    --app-texto: #1f2d38;
    --app-radio: 6px;
    --app-alto-control: 40px;
    --app-fuente: Arial, Helvetica, sans-serif;
}

/* Form controls use the page font (browsers default textareas to a typewriter font). */
button, input, select, textarea { font-family: var(--app-fuente); }

body {
    font-family: var(--app-fuente);
    color: var(--app-texto);
    background: var(--app-fondo);
}

/* ---------- Header and menu (cabecera.php) ---------- */
.app-cabecera {
    background: var(--app-oscuro);
    color: #fff;
    padding: 14px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.app-cabecera .app-marca { color: #fff; text-decoration: none; display: flex; flex-direction: column; }
.app-cabecera .app-marca strong { font-size: 22px; letter-spacing: .3px; }
.app-cabecera .app-marca span { font-size: 13px; color: #c5d1da; margin-top: 2px; }
.app-cabecera .app-usuario { font-size: 13px; color: #c5d1da; display: flex; align-items: center; gap: 12px; }
.app-cabecera .app-usuario a { color: #fff; font-weight: bold; text-decoration: none; padding: 6px 10px; border: 1px solid #5b7184; border-radius: var(--app-radio); }
.app-cabecera .app-usuario a:hover { background: #33495b; }
.app-cabecera .app-salir { margin: 0; }
.app-cabecera .app-salir button { color: #fff; font-weight: bold; font-size: 13px; background: transparent; padding: 6px 10px; border: 1px solid #5b7184; border-radius: var(--app-radio); cursor: pointer; }
.app-cabecera .app-salir button:hover { background: #33495b; }

.app-menu {
    background: #fff;
    border-bottom: 1px solid var(--app-borde);
    padding: 10px 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.app-menu a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: var(--app-radio);
    color: var(--app-texto);
    background: var(--app-gris-claro);
    text-decoration: none;
    font-size: 14px;
    font-weight: bold;
}
.app-menu a:hover { background: #dfe7ee; }
.app-menu a.app-activo { background: var(--app-primario-suave); color: var(--app-primario-oscuro); box-shadow: inset 0 0 0 1px #b9d8f0; }
.app-menu a.app-crear { background: var(--app-exito); color: #fff; }
.app-menu a.app-crear:hover { background: var(--app-exito-oscuro); }
.app-menu .app-separador { width: 1px; align-self: stretch; background: var(--app-borde); margin: 0 4px; }

/* Page title row: title on the left, actions (Volver...) on the right. */
.app-subtitulo, .app-titulo-pagina { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.app-subtitulo {
    background: #fff;
    border-bottom: 1px solid var(--app-borde);
    padding: 12px 30px;
    font-size: 18px;
    font-weight: bold;
    color: var(--app-oscuro);
}

@media (max-width: 760px) {
    .app-subtitulo { padding: 10px 16px; font-size: 16px; }
    .app-cabecera { padding: 12px 16px; }
    .app-cabecera .app-marca strong { font-size: 19px; }
    .app-menu { padding: 10px 12px; gap: 6px; }
    .app-menu a { flex: 1 1 calc(33.333% - 6px); justify-content: center; text-align: center; font-size: 13px; padding: 0 8px; min-height: 42px; }
    .app-menu a.app-crear { flex-basis: 100%; }
    .app-menu .app-separador { display: none; }
}

/* ---------- Page layout: same width, same title, same back button ---------- */
@media (min-width: 761px) {
    /* Every screen with the shared menu uses the full width with the same side margin. */
    .app-menu ~ .contenedor, .app-menu ~ main, .app-subtitulo ~ .contenedor, .app-subtitulo ~ main {
        box-sizing: border-box;
        width: auto;
        max-width: none;
        margin: 0;
        padding: 24px 30px;
    }
    /* Pages whose container is itself a white card keep the card, at full width. */
    .app-menu ~ .contenedor.app-tarjeta { margin: 24px 30px; padding: 25px; }
    /* Page title: one size and weight everywhere. */
    .app-subtitulo {
        background: transparent;
        border-bottom: 0;
        padding: 24px 30px 0;
        font-size: 26px;
    }
    .app-subtitulo + .contenedor, .app-subtitulo + main { padding-top: 18px; }
    .app-subtitulo + .contenedor.app-tarjeta { margin-top: 18px; }
    .contenedor > .titulo h1, .contenedor > .titulo h2, .contenedor > .barra h1,
    .a3jb-titulo-viaje h1, .app-menu ~ main > h1, .app-titulo-pagina h1 {
        margin: 0;
        font-size: 26px;
        font-weight: bold;
        color: var(--app-oscuro);
    }
    .contenedor > .titulo, .contenedor > .barra, .app-titulo-pagina { margin-bottom: 20px; }
    /* Card and section headings: one size below the page title. */
    .contenedor h2, .app-menu ~ main h2, .bloque h2, .tarjeta h2, .filtros h2, .seccion h2 { font-size: 20px; font-weight: bold; }
}

/* ---------- Form fields: same height, labels aligned ---------- */
.campo label, .dato label, .campo > label, .dato > label {
    line-height: 1.3;
    font-size: 13px;
    font-weight: bold;
    color: #34444f;
}
/* Required markers: same size as the label so every field in a row starts at the same height. */
.deca-requerido, .asterisco-informativo, .a3jb-tramo-requerido {
    font-size: inherit !important;
    line-height: 1 !important;
    color: var(--app-peligro) !important;
    font-weight: 800;
}
.grid, .grid3, .grid4, .fila, .a3jb-tramo-datos { align-items: start; }

.campo input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]),
.campo select,
.dato input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]),
.dato select {
    box-sizing: border-box;
    height: var(--app-alto-control);
    min-height: var(--app-alto-control);
    padding: 0 10px;
    border: 1px solid var(--app-borde);
    border-radius: var(--app-radio);
    font-family: var(--app-fuente);
    font-size: 14px;
}
.campo textarea, .dato textarea {
    border: 1px solid var(--app-borde);
    border-radius: var(--app-radio);
    font-family: var(--app-fuente);
    font-size: 14px;
}
.campo input:focus, .campo select:focus, .campo textarea:focus,
.dato input:focus, .dato select:focus, .dato textarea:focus {
    outline: none;
    border-color: var(--app-primario);
    box-shadow: 0 0 0 3px rgba(8, 118, 201, .15);
}
/* Large on/off option: the whole box (control height) is clickable. */
.casilla-grande {
    display: flex !important;
    align-items: center;
    gap: 10px;
    box-sizing: border-box;
    min-height: var(--app-alto-control);
    margin: 0 !important;
    padding: 0 12px;
    border: 1px solid var(--app-borde);
    border-radius: var(--app-radio);
    background: #fff;
    font-size: 14px;
    font-weight: 600 !important;
    cursor: pointer;
}
.casilla-grande input[type=checkbox] { width: 22px; height: 22px; margin: 0; cursor: pointer; accent-color: var(--app-primario); }
.casilla-grande:has(input:checked) { border-color: var(--app-primario); background: #eef6fd; }

/* Calculated (read-only) values: same box, just grey. */
.campo input[readonly], .dato input[readonly] {
    background: var(--app-gris-claro);
    color: #33424e;
    font-weight: 600;
}
@media (max-width: 680px) {
    .campo input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]),
    .campo select,
    .dato input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]),
    .dato select { height: 44px; min-height: 44px; font-size: 16px; }
}

/* ---------- Buttons: one style, every class family ---------- */
.btn, .boton, a.btn, a.boton, button.btn, button.boton, input.btn, input.boton,
.a3jb-anadir-tramo, .btn-exportar, .btn-confirmar, .btn-volver,
.boton-volver-viajes, a.volver, .boton.secundario {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-sizing: border-box;
    min-height: var(--app-alto-control);
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--app-radio);
    font-family: var(--app-fuente);
    font-size: 14px;
    font-weight: bold;
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
    background: var(--app-primario);
    color: #fff;
}
.btn:hover, .boton:hover, .a3jb-anadir-tramo:hover, .btn-exportar:hover, .btn-confirmar:hover { background: var(--app-primario-oscuro); color: #fff; }

/* Primary (blue) */
.btn-azul, .boton-azul, .boton-guardar-viaje, .btn-confirmar { background: var(--app-primario) !important; color: #fff !important; border-color: transparent !important; }
.btn-azul:hover, .boton-azul:hover, .boton-guardar-viaje:hover { background: var(--app-primario-oscuro) !important; }
/* Success (green): create / export */
.btn-verde, .boton-verde, .btn-exportar { background: var(--app-exito) !important; color: #fff !important; border-color: transparent !important; }
.btn-verde:hover, .boton-verde:hover, .btn-exportar:hover { background: var(--app-exito-oscuro) !important; }
/* Danger (red) */
.btn-rojo, .boton-rojo, .boton-peligro, .a3jb-tramo-quitar { background: #fff !important; color: var(--app-peligro) !important; border: 1px solid #e3a5a5 !important; }
.btn-rojo:hover, .boton-rojo:hover, .boton-peligro:hover, .a3jb-tramo-quitar:hover { background: var(--app-peligro-suave) !important; }
/* Secondary (grey / back) */
.btn-gris, .boton-gris, .btn-volver, .boton-volver, .boton-volver-viajes, a.volver, .boton.volver, .boton.secundario {
    background: #fff !important; color: var(--app-oscuro) !important; border: 1px solid var(--app-borde) !important; box-shadow: none !important;
}
.btn-gris:hover, .boton-gris:hover, .btn-volver:hover, .boton-volver:hover, .boton-volver-viajes:hover,
a.volver:hover, .boton.volver:hover, .boton.secundario:hover { background: var(--app-gris-claro) !important; color: var(--app-oscuro) !important; }
.btn:disabled, .boton:disabled, .a3jb-anadir-tramo:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Cards / sections ---------- */
.bloque, .seccion, .tarjeta, .filtros, .resumen {
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(20, 40, 60, .08);
    border: 1px solid #e3e8ec;
}
.bloque h2, .seccion h2, .tarjeta h2, .filtros h2 { color: var(--app-oscuro); }

/* ---------- Tables: same look in every list ---------- */
table.tabla, .contenedor table, .tabla-contenedor table, .tabla-wrap table, .app-menu ~ main table {
    border-collapse: collapse;
    background: #fff;
    font-size: 13px;
}
table.tabla th, .contenedor table th, .tabla-contenedor table th, .tabla-wrap table th, .app-menu ~ main table th {
    background: var(--app-oscuro);
    color: #fff;
    font-size: 12.5px;
    font-weight: bold;
    text-align: left;
    padding: 10px 10px;
    border-bottom: 0;
}
table.tabla td, .contenedor table td, .tabla-contenedor table td, .tabla-wrap table td, .app-menu ~ main table td {
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid #e6ebef;
    vertical-align: middle;
}
table.tabla tbody tr:nth-child(even) td, .contenedor table tbody tr:nth-child(even) td, .app-menu ~ main table tbody tr:nth-child(even) td { background: #f9fbfc; }
/* Money columns of the trips list (PVP, Coste, Margen, % margen) line up on the right. */
/* Trips list: text on the left like every other list, money on the right. */
table.app-tabla-viajes th, table.app-tabla-viajes td { text-align: left; }
table.app-tabla-viajes th:nth-child(n+11):nth-child(-n+14),
table.app-tabla-viajes td:nth-child(n+11):nth-child(-n+14) { text-align: right; }
/* Icon columns (orders, DECA, documents...) stay centred under their header. */
table.app-tabla-viajes th:nth-child(n+15),
table.app-tabla-viajes td:nth-child(n+15) { text-align: center; }

table.tabla tbody tr:hover td, .contenedor table tbody tr:hover td { background: #eef6fd; }

/* Links in the primary color */
.contenedor a:not(.btn):not(.boton):not([class*="btn-"]):not([class*="boton-"]) { color: var(--app-primario-oscuro); }

/* "+ Nuevo contacto / dirección / conductor": light secondary actions, same size as other buttons. */
@media (min-width: 681px) {
    button[id^="a3jb_nuevo_"], button.a3jb-nueva-direccion, button.a3jb-dir-action, button.a3jb-boton-nuevo-conductor,
    button.a3jb-nuevo-contacto-cliente, button.a3jb-nuevo-contacto-proveedor {
        min-height: var(--app-alto-control) !important;
        height: auto !important;
        padding: 0 14px !important;
        font-size: 14px !important;
        border-radius: var(--app-radio) !important;
    }
}

/* ---------- Search boxes of the simple lists (Clientes, Proveedores, Direcciones): one look ---------- */
.buscador-listado label { font-size: 13px !important; font-weight: bold; color: #34444f !important; margin-bottom: 6px; }
.buscador-listado input {
    box-sizing: border-box;
    width: 100%;
    max-width: 550px !important;
    height: var(--app-alto-control) !important;
    padding: 0 12px !important;
    border: 1px solid var(--app-borde) !important;
    border-radius: var(--app-radio) !important;
    font: 14px var(--app-fuente) !important;
}
.buscador-listado input:focus { outline: none !important; border-color: var(--app-primario) !important; box-shadow: 0 0 0 3px rgba(8, 118, 201, .15); }
@media (max-width: 680px) { .buscador-listado input { height: 44px !important; font-size: 16px !important; max-width: none !important; } }

/* ---------- Trip documents box (ver-viaje.php) ---------- */
.docs-viaje h2 { margin-top: 0; }
.docs-viaje-fila { padding: 14px 0; border-top: 1px solid var(--app-borde); }
.docs-viaje-fila:first-of-type { border-top: 0; padding-top: 4px; }
.docs-viaje-transportista { margin-bottom: 10px; }
.docs-viaje-estados { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.docs-viaje-nombre { font-weight: bold; }
.docs-viaje-separador { color: var(--app-gris); }
.docs-viaje-estado { color: var(--app-gris); }
.docs-viaje-estado-ok { color: var(--app-exito); font-weight: bold; }
.docs-viaje-estado-aviso { color: #9a5b00; font-weight: bold; }
.docs-viaje-aviso { margin-top: 12px; padding: 10px 12px; background: #fff4e5; border: 1px solid #f0c36d; border-radius: var(--app-radio); }
.docs-viaje-acciones { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.docs-viaje-canal { font-weight: bold; margin-right: 6px; }
.docs-viaje-acciones { align-items: flex-start; }
.docs-viaje-canal { padding-top: 9px; }
.docs-viaje-envio { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; max-width: 190px; }
.docs-viaje-envio-texto { font-size: 13px; color: var(--app-gris); line-height: 1.3; }
.docs-viaje-envio .boton-pendiente + .docs-viaje-envio-texto { color: var(--app-peligro-oscuro); font-weight: bold; }
.docs-viaje-dar-enviada { margin: 0; }
.docs-viaje-enlace { padding: 0; border: 0; background: none; color: var(--app-primario); font-size: 13px; text-decoration: underline; cursor: pointer; }
.docs-viaje.bloqueado-por-cambios .docs-viaje-enlace { opacity: .45; pointer-events: none; }
.docs-viaje-ok { margin: 0 0 14px; padding: 12px 14px; background: #e8f6ee; border: 1px solid #9fd3b4; border-radius: var(--app-radio); color: var(--app-exito-oscuro); font-weight: bold; }

/* ---------- "Falta por enviar": one look for every pending send ---------- */
.app-pendiente { margin: 12px 0; padding: 14px 16px; background: var(--app-peligro-suave); border: 1px solid #e3a5a5; border-left: 6px solid var(--app-peligro); border-radius: var(--app-radio); color: var(--app-texto); }
.app-pendiente-titulo { display: block; margin-bottom: 4px; color: var(--app-peligro-oscuro); font-size: 16px; font-weight: bold; }
.app-pendiente p { margin: 4px 0 0; line-height: 1.45; }
.app-pendiente ul { margin: 6px 0 0; padding-left: 20px; }
.app-pendiente li { margin: 4px 0; }
.app-pendiente-acciones { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.app-pendiente form { margin: 0; }
a.boton-pendiente, button.boton-pendiente, .boton-pendiente { background: var(--app-peligro) !important; color: #fff !important; border-color: transparent !important; }
a.boton-pendiente:hover, button.boton-pendiente:hover, .boton-pendiente:hover { background: var(--app-peligro-oscuro) !important; }
.docs-viaje-estado-pendiente { color: var(--app-peligro); font-weight: bold; }

/* ---------- Unsaved changes bar (ver-viaje.php) ---------- */
.cambios-sin-guardar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px; padding: 12px 16px; background: var(--app-oscuro); color: #fff; box-shadow: 0 -2px 10px rgba(0,0,0,.2); }
.cambios-sin-guardar[hidden] { display: none; }
.cambios-sin-guardar strong { font-size: 16px; }
body.con-cambios-sin-guardar { padding-bottom: 76px; }
.docs-viaje.bloqueado-por-cambios a.boton, .docs-viaje.bloqueado-por-cambios .app-pendiente a { opacity: .45; pointer-events: none; }
.docs-viaje-aviso-guardar { margin-top: 10px; font-weight: bold; color: var(--app-peligro-oscuro); }

/* Trips list fits the screen: headers wrap instead of pushing the last columns out of view. */
table.app-tabla-viajes th { white-space: normal; }
table.app-tabla-viajes th, table.app-tabla-viajes td { padding-left: 6px; padding-right: 6px; }
table.app-tabla-viajes .estado-viaje { width: 104px; max-width: 104px; }

/* Multi-file upload (js/a3jb-subida-pdf.js): chosen files, in the order they are joined into one PDF. */
.a3jb-pdf-caja { margin-top: 6px; font-size: 13px; }
.a3jb-pdf-ayuda { margin: 0 0 6px; color: #5a6b78; }
.a3jb-pdf-lista { margin: 0; padding-left: 22px; }
.a3jb-pdf-lista:empty { display: none; }
.a3jb-pdf-lista li { padding: 4px 0; border-bottom: 1px solid var(--app-borde); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.a3jb-pdf-nombre { font-weight: bold; word-break: break-all; }
.a3jb-pdf-lista small { color: #5a6b78; }
.a3jb-pdf-botones { margin-left: auto; display: inline-flex; gap: 4px; }
.a3jb-pdf-botones button { min-width: 30px; padding: 2px 8px; font-size: 14px; line-height: 1.4; border: 1px solid var(--app-borde); border-radius: var(--app-radio); background: #fff; color: #23384a; cursor: pointer; }
.a3jb-pdf-botones button:disabled { opacity: .35; cursor: default; }
.a3jb-pdf-error { margin: 6px 0 0; padding: 6px 8px; border-radius: var(--app-radio); background: #fdecea; color: #a12622; }


/* Save bar always visible at the bottom of long forms (client and supplier pages), like the quote page. */
.app-barra-guardar, .botones.app-barra-guardar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin: 0; padding: 12px 16px; background: #fff; border-top: 1px solid #cbd5dc; box-shadow: 0 -2px 10px rgba(0,0,0,.12); }
body:has(.app-barra-guardar) { padding-bottom: 80px; }
