/* ==========================================================================
   SAPITO WEB — theme.css
   Única fuente de verdad de estilos compartidos: tokens, reset, tipografía,
   movimiento y componentes comunes (topbar, card, form, tabla, toast...).
   Cada página solo conserva en su <style> lo que es propio de su pantalla.
   Paleta: celeste oscuro (petróleo) sobre grises azulados.
   ========================================================================== */

/* ── Tokens ───────────────────────────────────────────────────────────── */
:root {
    /* Superficies */
    --bg:            #edf3f6;
    --surface:       #ffffff;
    --surface2:      #f6fafc;
    --border:        #d6e2e8;
    --border2:       #b7c9d3;
    --row-line:      #e3edf2;

    /* Acento: celeste oscuro */
    --accent:        #0b5d7a;
    --accent-hover:  #084a62;
    --accent-active: #063a4d;
    --accent-bg:     #dff0f6;
    --accent-soft:   #cfe4ec;
    --accent-border: #8cc4d8;
    --accent-ring:   rgba(11,93,122,.16);

    /* Texto */
    --text:          #0f1f27;
    --text2:         #3b4f5a;
    --muted:         #5f7683;

    /* Estados */
    --green:         #1a6e3a;
    --green-bg:      #e6f5ec;
    --green-border:  #2e9e5a;
    --red:           #9e2222;
    --red-bg:        #fce8e8;
    --red-border:    #d96a6a;
    --amber:         #7c4f00;
    --amber-bg:      #fff8e6;

    /* Forma */
    --radius:        8px;
    --radius-lg:     12px;
    --radius-pill:   999px;

    /* Sombras en capas (más naturales que una sola difusa) */
    --shadow-sm:  0 1px 2px rgba(15,31,39,.05), 0 1px 3px rgba(15,31,39,.04);
    --shadow-md:  0 1px 2px rgba(15,31,39,.05), 0 4px 12px rgba(15,31,39,.07);
    --shadow-pop: 0 2px 4px rgba(15,31,39,.06), 0 10px 28px rgba(15,31,39,.14);

    /* Movimiento: curvas fuertes; las integradas de CSS son demasiado tibias */
    --ease-out:    cubic-bezier(.23, 1, .32, 1);
    --ease-in-out: cubic-bezier(.77, 0, .175, 1);
    --dur-fast:    .12s;   /* hover, color */
    --dur:         .18s;   /* press, toggles */
    --dur-slow:    .28s;   /* entradas, toasts */
}

/* ── Reset y base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 14px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
button, input, select, textarea { font-family: inherit; }
th, td, .num { font-variant-numeric: tabular-nums; }
::selection { background: var(--accent-bg); color: var(--accent-active); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* ── Botones: feedback inmediato al presionar ─────────────────────────── */
button, [class*="btn"] {
    transition: background-color var(--dur-fast) var(--ease-out),
                border-color var(--dur-fast) var(--ease-out),
                color var(--dur-fast) var(--ease-out),
                box-shadow var(--dur) var(--ease-out),
                transform var(--dur) var(--ease-out),
                opacity var(--dur-fast) var(--ease-out);
}
button:not(:disabled):active,
a[class*="btn"]:active,
[class*="btn"]:not(:disabled):active { transform: scale(.97); }
button:disabled, [class*="btn"]:disabled { cursor: not-allowed; opacity: .55; }

.btn-submit:hover  { background: var(--accent-hover); }
.btn-submit:active { background: var(--accent-active); }
.btn-buscar:hover,
.btn-primary:hover { background: var(--accent-hover); }

/* ── Topbar ───────────────────────────────────────────────────────────── */
.topbar {
    display: flex; align-items: center; gap: 1rem;
    position: sticky; top: 0; z-index: 10;
    padding: .75rem 1.5rem;
    background: var(--surface);
    border-bottom: 2px solid var(--border);
    box-shadow: var(--shadow-md);
}
.topbar h1 { flex: 1; font-size: 1rem; font-weight: 600; color: var(--text); }
.topbar a {
    display: flex; align-items: center; gap: .3rem;
    color: var(--accent); text-decoration: none;
    font-size: .82rem; font-weight: 500;
    transition: opacity var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.topbar a:hover { opacity: .7; }
.user, .topbar .user {
    font-size: .78rem; color: var(--muted);
    background: var(--bg); border: 1px solid var(--border);
    padding: .2rem .6rem; border-radius: 20px;
}

/* ── Card ─────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-header {
    padding: .65rem 1.25rem; background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: .72rem; font-weight: 600; color: var(--muted);
    letter-spacing: .07em; text-transform: uppercase;
}
.card-body { padding: 1.5rem; }
.section-title {
    font-size: .72rem; font-weight: 600; color: var(--muted);
    letter-spacing: .07em; text-transform: uppercase; margin-bottom: .65rem;
}
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.empty { text-align: center; padding: 3rem 2rem; color: var(--muted); font-size: .9rem; }

/* ── Formularios ──────────────────────────────────────────────────────── */
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
.field label {
    display: block; font-size: .78rem; font-weight: 600;
    color: var(--text2); margin-bottom: .35rem;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}
input, select, textarea {
    transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}

/* ── Avisos ───────────────────────────────────────────────────────────── */
.error-box {
    background: var(--red-bg); border: 1px solid var(--red-border);
    border-radius: var(--radius); padding: 1rem 1.25rem;
    color: var(--red); font-size: .85rem; margin-bottom: 1rem;
}
.toast.ok    { background: var(--green-bg); border: 1.5px solid var(--green-border); color: var(--green); }
.toast.error { background: var(--red-bg);   border: 1.5px solid #c94040;            color: var(--red); }

/* ── Tablas ───────────────────────────────────────────────────────────── */
tbody tr { transition: background-color var(--dur-fast) var(--ease-out); }
tbody tr:hover { background: color-mix(in srgb, var(--accent-bg) 55%, transparent); }

/* ── Listas de navegación (embarques) ─────────────────────────────────── */
.embarque-list { list-style: none; }
.embarque-item { border-bottom: 1px solid var(--border); }
.embarque-item:last-child { border-bottom: none; }
.embarque-link {
    display: flex; align-items: center; gap: 1rem; padding: .9rem 1.25rem;
    text-decoration: none;
    transition: background-color var(--dur-fast) var(--ease-out);
}
.embarque-link:hover { background: var(--accent-bg); }
.embarque-info { flex: 1; }
.embarque-nombre { font-size: .88rem; font-weight: 500; color: var(--text); }
.embarque-fecha  { font-size: .75rem; color: var(--muted); margin-top: .1rem; }
.embarque-arrow  { font-size: .8rem; color: var(--muted); }

/* ── Iconos: trazo uniforme (estilo Lucide) ───────────────────────────── */
.icon {
    width: 1em; height: 1em; flex-shrink: 0;
    fill: none; stroke: currentColor; stroke-width: 2;
    stroke-linecap: round; stroke-linejoin: round;
}

/* ── Animaciones compartidas ──────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Accesibilidad: sin movimiento, solo fundidos cortos */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
    /* Un spinner quieto parece roto: se mantiene girando */
    .spinner { animation-duration: 1.2s !important; animation-iteration-count: infinite !important; }
}
