﻿/* =========================================================================
   Ecatrans · Consultas Web
   Sistema visual corporativo B2B (alineado con ecatranscr.com)
   ========================================================================= */

:root {
    --blue: #0A4D92;
    --blue-600: #083F78;
    --blue-50: #E8F0F9;
    --navy: #0B2545;
    --navy-700: #12325C;
    --red: #C01920;
    --green: #00B050;
    --green-700: #008A3E;
    --bg: #F8F9FA;
    --surface: #FFFFFF;
    --line: #DDE3EA;
    --line-soft: #EAEEF3;
    --ink: #0B2545;
    --text: #4A5668;
    --muted: #76839A;

    --radius: 8px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(11, 37, 69, .06), 0 1px 3px rgba(11, 37, 69, .06);
    --shadow-md: 0 6px 20px -6px rgba(11, 37, 69, .18), 0 2px 6px rgba(11, 37, 69, .06);
    --shadow-lg: 0 24px 48px -12px rgba(11, 37, 69, .35);

    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --font: 'Montserrat', 'Poppins', 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
    --gutter: 16px;
    --topbar-h: 72px;
}

/* ---- Reset ligero ---------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(10, 77, 146, .45); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---- Botones --------------------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 20px;
    border: 1px solid transparent; border-radius: var(--radius);
    font-weight: 600; font-size: 15px; line-height: 1; white-space: nowrap;
    cursor: pointer; text-decoration: none !important;
    transition: transform 160ms var(--ease-out), background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-600); }
.btn-accent { background: var(--red); color: #fff; }
.btn-accent:hover:not(:disabled) { background: #A51319; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: var(--green-700); }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .35); }
.btn-ghost:hover { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .6); }
.btn-outline { background: #fff; color: var(--blue); border-color: var(--line); }
.btn-outline:hover:not(:disabled) { border-color: var(--blue); background: var(--blue-50); }
.btn-lg { min-height: 56px; padding: 0 28px; font-size: 16px; }
.btn-block { width: 100%; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading .btn-label { opacity: .0; }
.btn.is-loading::after {
    content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: spin .6s linear infinite;
}
.btn { position: relative; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Barra superior -------------------------------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    height: var(--topbar-h);
    background: var(--navy);
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.topbar .wrap { height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 14px; color: #fff; min-width: 0; text-decoration: none !important; }
.brand img { height: 36px; width: auto; display: block; }
.brand-sub {
    padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, .25);
    font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; line-height: 1.3;
    color: rgba(255, 255, 255, .8);
}
.topnav { display: flex; align-items: center; gap: 8px; }
.topnav .nav-link {
    color: rgba(255, 255, 255, .8); font-weight: 600; font-size: 14px; padding: 10px 14px; border-radius: var(--radius);
    transition: background-color 160ms ease, color 160ms ease; text-decoration: none !important;
}
.topnav .nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.topnav .nav-link.is-active { color: #fff; background: rgba(255, 255, 255, .12); }
.user-chip {
    display: flex; align-items: center; gap: 10px; padding: 4px 14px 4px 4px; margin-left: 4px;
    background: rgba(255, 255, 255, .08); border-radius: 999px; color: #fff; max-width: 260px;
}
.avatar {
    flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: 14px; border: 1px solid rgba(255, 255, 255, .3);
}
.user-chip span.name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-logout { min-height: 40px; padding: 0 16px; font-size: 14px; }

/* ---- Hero ------------------------------------------------------------ */
.hero {
    position: relative; color: #fff; overflow: hidden;
    background:
        radial-gradient(1000px 420px at 85% -10%, rgba(10, 77, 146, .85), transparent 60%),
        linear-gradient(180deg, var(--navy) 0%, var(--navy-700) 100%);
    padding: 64px 0 150px;
}
.hero::before {
    content: ""; position: absolute; inset: 0; opacity: .5; pointer-events: none;
    background-image: linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
    background-size: 56px 56px;
    -webkit-mask-image: linear-gradient(180deg, #000, transparent 85%); mask-image: linear-gradient(180deg, #000, transparent 85%);
}
.hero .wrap { position: relative; }
.eyebrow {
    display: inline-flex; align-items: center; gap: 8px; margin-bottom: 18px;
    font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #9DC3EE;
}
.eyebrow::before { content: ""; width: 24px; height: 2px; background: var(--red); }
.hero h1 { color: #fff; font-size: clamp(30px, 4.6vw, 52px); font-weight: 700; max-width: 18ch; }
.hero .lead { margin-top: 18px; max-width: 58ch; font-size: clamp(16px, 1.6vw, 18px); color: rgba(255, 255, 255, .8); }
.hero-wave { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 90px; display: block; }

/* ---- Búsqueda -------------------------------------------------------- */
.search-card {
    position: relative; z-index: 2; margin-top: -92px;
    background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    padding: 24px; border-top: 4px solid var(--blue);
}
.search-card label.field-label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; color: var(--ink); letter-spacing: .02em; }
.search-row { display: flex; gap: 12px; }
.input-wrap { position: relative; flex: 1; min-width: 0; }
.input-wrap > .fa-search { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 18px; }
.input {
    width: 100%; height: 56px; padding: 0 16px; background: #fff;
    border: 1.5px solid var(--line); border-radius: var(--radius); font-size: 17px; font-weight: 500; color: var(--ink);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}
.input::placeholder { color: #9AA6B8; font-weight: 400; }
.input:hover { border-color: #B8C4D4; }
.input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(10, 77, 146, .14); }
.input.with-icon { padding-left: 50px; padding-right: 48px; }
.input-clear {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border: 0; border-radius: 50%;
    background: transparent; color: var(--muted); cursor: pointer; display: none; transition: background-color 160ms ease;
}
.input-clear:hover { background: var(--line-soft); }
.input-wrap.has-value .input-clear { display: block; }
.recent { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.chip {
    padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--ink);
    font-size: 13px; font-weight: 600; cursor: pointer; transition: background-color 160ms ease, border-color 160ms ease, transform 160ms var(--ease-out);
}
.chip:hover { border-color: var(--blue); background: var(--blue-50); }
.chip:active { transform: scale(.97); }

/* ---- Tarjetas informativas ------------------------------------------ */
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding: 40px 0 8px; }
.feature {
    background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 220ms var(--ease-out), box-shadow 220ms ease, border-color 220ms ease;
}
@media (hover: hover) { .feature:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line); } }
.icon-circle {
    width: 48px; height: 48px; border-radius: 50%; background: var(--blue); color: #fff;
    display: grid; place-items: center; font-size: 20px; margin-bottom: 16px;
}
.icon-circle.green { background: var(--green); }
.icon-circle.red { background: var(--red); }
.feature h3 { font-size: 18px; margin-bottom: 8px; }
.feature p { font-size: 15px; }

.access-band {
    margin: 28px 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
    padding: 28px 32px; border-radius: var(--radius-lg); color: #fff;
    background: linear-gradient(110deg, var(--blue) 0%, var(--navy) 100%);
}
.access-band h3 { color: #fff; font-size: 22px; margin-bottom: 4px; }
.access-band p { color: rgba(255, 255, 255, .8); max-width: 60ch; }

/* ---- Resultados ------------------------------------------------------ */
.results { padding: 32px 0 48px; scroll-margin-top: calc(var(--topbar-h) + 8px); }
.results-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.results-head h2 { font-size: 24px; }
.results-head .meta { font-size: 14px; color: var(--muted); margin-top: 4px; }
.reveal { animation: reveal 260ms var(--ease-out) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- Tabla ----------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.table-card { overflow: hidden; }
.table-scroll { overflow: auto; max-height: calc(100vh - 340px); min-height: 220px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 15px; color: var(--ink); min-width: 980px; }
.data-table thead th {
    position: sticky; top: 0; z-index: 2; background: #EEF3F9; color: var(--navy);
    padding: 14px 16px; font-size: 12.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; text-align: left; white-space: nowrap;
    border-bottom: 2px solid var(--blue);
}
.data-table td { padding: 15px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: top; background: #fff; }
.data-table tbody tr { transition: background-color 120ms ease; }
.data-table tbody tr:hover td { background: #F3F7FC; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table th.num { text-align: right; }
.data-table .nowrap { white-space: nowrap; }
.data-table .strong { font-weight: 700; color: var(--navy); }
.data-table .desc { min-width: 220px; max-width: 360px; }
.data-table .obs { min-width: 200px; max-width: 320px; color: var(--text); }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.badge-ok { background: rgba(0, 176, 80, .12); color: var(--green-700); }
.badge-zero { background: var(--line-soft); color: var(--muted); }
.cell-muted { color: var(--muted); }
.mov-link { font-weight: 700; color: var(--blue); }

.state { text-align: center; padding: 56px 24px; }
.state .icon-circle { margin: 0 auto 16px; width: 56px; height: 56px; font-size: 24px; }
.state h3 { font-size: 18px; margin-bottom: 6px; }
.state p { color: var(--muted); max-width: 46ch; margin: 0 auto; }

.skeleton-row { display: grid; grid-template-columns: 90px 110px 1fr 90px 80px 80px; gap: 16px; padding: 18px 16px; border-bottom: 1px solid var(--line-soft); }
.sk { height: 16px; border-radius: 6px; background: linear-gradient(90deg, #EAEEF3 25%, #F5F7FA 50%, #EAEEF3 75%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---- Panel principal (autenticado) ---------------------------------- */
.page-head { background: var(--navy); color: #fff; padding: 28px 0 72px; position: relative; }
.page-head h1 { color: #fff; font-size: clamp(24px, 3vw, 32px); }
.page-head p { color: rgba(255, 255, 255, .75); margin-top: 6px; }
.toolbar {
    position: relative; z-index: 2; margin-top: -48px; padding: 20px;
    display: grid; grid-template-columns: 150px 190px minmax(240px, 1fr) auto; gap: 16px; align-items: end;
    border-top: 4px solid var(--blue);
}
.toolbar .field label { display: block; margin-bottom: 6px; font-size: 12.5px; font-weight: 700; color: var(--ink); letter-spacing: .04em; text-transform: uppercase; }
.select {
    width: 100%; height: 48px; padding: 0 40px 0 14px; border: 1.5px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--ink); font-weight: 500;
    appearance: none; -webkit-appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2376839A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 14px center;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}
.select:hover { border-color: #B8C4D4; }
.select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(10, 77, 146, .14); }
.toolbar .input { height: 48px; font-size: 16px; }

.panel { margin: 20px 0 48px; }
.panel-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 14px 20px; border-bottom: 1px solid var(--line-soft);
}
.panel-bar .count { font-size: 15px; color: var(--text); }
.panel-bar .count b { color: var(--ink); font-size: 17px; }
.pager { display: flex; align-items: center; gap: 6px; }
.pager button {
    min-width: 40px; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; color: var(--blue);
    font-weight: 600; font-size: 14px; cursor: pointer;
    transition: transform 160ms var(--ease-out), background-color 160ms ease, border-color 160ms ease;
}
.pager button:hover:not(:disabled) { background: var(--blue-50); border-color: var(--blue); }
.pager button:active:not(:disabled) { transform: scale(.95); }
.pager button:disabled { color: #B3BECE; cursor: not-allowed; background: var(--bg); }
.pager .page-ind { padding: 0 12px; font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.panel .table-scroll { max-height: calc(100vh - 380px); }

/* ---- Login (diálogo) ------------------------------------------------- */
.dialog-backdrop {
    position: fixed; inset: 0; z-index: 100; background: rgba(11, 37, 69, .6); backdrop-filter: blur(3px);
    display: grid; place-items: center; padding: 16px; opacity: 0; visibility: hidden;
    transition: opacity 200ms ease, visibility 0s linear 200ms;
}
.dialog-backdrop.is-open { opacity: 1; visibility: visible; transition-delay: 0s; }
.dialog {
    width: 100%; max-width: 420px; background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); overflow: hidden;
    transform: translateY(12px) scale(.96); transition: transform 220ms var(--ease-out);
}
.dialog-backdrop.is-open .dialog { transform: none; }
.dialog-head { background: var(--navy); padding: 24px 28px; color: #fff; position: relative; }
.dialog-head h2 { color: #fff; font-size: 22px; }
.dialog-head p { margin-top: 4px; color: rgba(255, 255, 255, .75); font-size: 14px; }
.dialog-close {
    position: absolute; right: 14px; top: 14px; width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: rgba(255, 255, 255, .8); cursor: pointer;
    transition: background-color 160ms ease;
}
.dialog-close:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.dialog-body { padding: 28px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 700; color: var(--ink); }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 52px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 50%; }
.pw-toggle:hover { background: var(--line-soft); }
.form-error { display: none; margin-bottom: 16px; padding: 10px 14px; border-radius: var(--radius); background: rgba(192, 25, 32, .08); color: var(--red); font-size: 14px; font-weight: 600; }
.form-error.is-visible { display: block; }
.input.is-invalid { border-color: var(--red); }
.dialog-note { margin-top: 16px; text-align: center; font-size: 13px; color: var(--muted); }

/* ---- Pie ------------------------------------------------------------- */
.site-footer { margin-top: auto; background: var(--navy); color: rgba(255, 255, 255, .75); font-size: 14px; }
.site-footer .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 22px; padding-bottom: 22px; }
.site-footer a { color: rgba(255, 255, 255, .85); margin-left: 16px; }
.site-footer a:hover { color: #fff; }

/* ---- Alertify (alineado a la marca) --------------------------------- */
.alertify-notifier .ajs-message { border-radius: var(--radius); font-family: var(--font); font-weight: 600; font-size: 14px; box-shadow: var(--shadow-md); text-shadow: none; }
.alertify-notifier .ajs-message.ajs-success { background: var(--green); }
.alertify-notifier .ajs-message.ajs-error { background: var(--red); }
.alertify-notifier .ajs-message.ajs-warning { background: var(--navy); color: #fff; }
.alertify-notifier .ajs-message.ajs-warning, .alertify-notifier .ajs-message.ajs-error, .alertify-notifier .ajs-message.ajs-success { color: #fff; }

/* ---- Responsive ------------------------------------------------------ */
@media (max-width: 1024px) {
    .toolbar { grid-template-columns: 1fr 1fr; }
    .toolbar .field-search { grid-column: 1 / -1; order: -1; }
    .toolbar .field-export { grid-column: 1 / -1; }
    .toolbar .field-export .btn { width: 100%; }
}
@media (max-width: 860px) {
    .features { grid-template-columns: 1fr; padding-top: 28px; }
    .brand-sub { display: none; }
    .user-chip span.name { display: none; }
    .user-chip { padding-right: 4px; }
}
@media (max-width: 720px) {
    :root { --topbar-h: 64px; }
    .hero { padding: 40px 0 130px; }
    .search-card { padding: 18px; margin-top: -80px; }
    .search-row { flex-direction: column; }
    .search-row .btn { width: 100%; }
    .access-band { padding: 22px; }
    .access-band .btn { width: 100%; }
    .topnav .nav-link { display: none; }
    .toolbar { grid-template-columns: 1fr; }
    .panel-bar { flex-direction: column; align-items: stretch; }
    .pager { justify-content: space-between; gap: 4px; }
    .pager button { min-width: 38px; padding: 0 8px; }
    .pager .page-ind { padding: 0 4px; font-size: 13px; }

    /* La tabla se convierte en tarjetas apiladas */
    .table-scroll { max-height: none; overflow: visible; }
    .data-table { min-width: 0; display: block; }
    .data-table thead { display: none; }
    .data-table tbody { display: block; }
    .data-table tbody tr { display: block; padding: 14px 16px; border-bottom: 8px solid var(--bg); }
    .data-table td { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border: 0; background: transparent !important; text-align: right !important; white-space: normal !important; max-width: none !important; min-width: 0 !important; }
    .data-table td::before { content: attr(data-label); flex: none; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; text-align: left; padding-top: 2px; }
    .data-table td:empty { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
