/* =====================================================================
   Portal Pro Ley — sistema de diseño.
   Estructura adoptada del portal "Ecuador en Portugal"; paleta de Pro Ley
   (teal #1A444D + rojo #B70000). CSS plano (sin build).
   ===================================================================== */
:root {
    /* ---- Marca: teal Pro Ley ---- */
    --color-oro-50:  #eef4f5;
    --color-oro-100: #d5e5e7;
    --color-oro-200: #aecccf;
    --color-oro-300: #7faab0;
    --color-oro-400: #4f858d;
    --color-oro-500: #2f6771;   /* teal medio */
    --color-oro-600: #23545d;
    --color-oro-700: #1A444D;    /* teal base de la marca */
    --color-oro-800: #123138;
    --color-crema:   #d5e5e7;

    /* ---- Neutros fríos ---- */
    --color-marfil:  #f2f5f6;   /* fondo de página */
    --color-tinta:   #1c2b2f;   /* texto principal */
    --color-tinta-2: #5b6b70;   /* texto secundario */
    --color-linea:   #dfe7e9;   /* hairlines */

    /* ---- Semánticos ---- */
    --color-exito:   #1a7f37;
    --color-alerta:  #b70000;   /* rojo Pro Ley */

    /* ---- Tipografía (misma de Ecuador) ---- */
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji',
        'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--color-marfil);
    color: var(--color-tinta);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { text-wrap: balance; }
a { color: var(--color-oro-700); }

/* ============ Formularios ============ */
.field-label { display: block; font-size: .875rem; font-weight: 500; color: var(--color-tinta-2); margin-bottom: 6px; }
.field-input {
    width: 100%; border-radius: 12px; border: 1px solid var(--color-oro-200); background: #fff;
    padding: 12px 16px; font-size: 15px; color: var(--color-tinta);
    box-shadow: 0 1px 2px rgba(0,0,0,.03); transition: border .15s, box-shadow .15s;
}
.field-input::placeholder { color: rgba(91,107,112,.5); }
.field-input:focus { outline: none; border-color: var(--color-oro-400); box-shadow: 0 0 0 4px rgba(79,133,141,.15); }

/* ============ Botones ============ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border-radius: 12px; font-weight: 600; font-size: 15px; padding: 12px 20px;
    transition: background .15s, filter .15s; user-select: none; cursor: pointer;
    border: 0; text-decoration: none;
}
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(79,133,141,.25); }
.btn-primary { background: var(--color-oro-700); color: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.btn-primary:hover { background: var(--color-oro-800); }
.btn-ghost { background: #fff; color: var(--color-oro-700); border: 1px solid var(--color-oro-200); }
.btn-ghost:hover { background: var(--color-oro-50); }
.btn-whatsapp { background: #25D366; color: #fff; }
.btn-whatsapp:hover { filter: brightness(.95); }
.btn-sm { padding: 5px 12px; font-size: .82rem; }

/* ============ Alertas ============ */
.alert { border-radius: 12px; padding: 12px 16px; font-size: .9rem; margin-bottom: 16px; }
.alert-error { background: #fbecea; color: #8a1c1c; border: 1px solid #f0c7c2; }
.alert-ok    { background: #e6f4ea; color: #1e7e34; border: 1px solid #bfe3c9; }
.alert-warn, .alert-staff { background: #fdf3d8; color: #7a5a00; border: 1px solid #f0dca6; }

/* ---------- Topbar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    height: 64px; padding: 0 24px;
    background: rgba(255,255,255,0.92); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--color-linea);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar .brand { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; color: var(--color-oro-700); text-decoration: none; }
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: .9rem; color: var(--color-tinta-2); }
.topbar .user form { margin: 0; }
.topbar .llave {
    font-size: .8rem; color: var(--color-tinta-2);
    background: var(--color-oro-50); border: 1px solid var(--color-oro-100);
    padding: 4px 10px; border-radius: 999px;
}
.sidebar-toggle { display: none; background: none; border: 0; cursor: pointer; font-size: 1.4rem; color: var(--color-tinta-2); padding: 4px 8px; border-radius: 8px; }
.sidebar-toggle:hover { background: var(--color-oro-50); }

/* ---------- Layout ---------- */
.layout { display: flex; align-items: stretch; min-height: calc(100vh - 64px); }
.sidebar-backdrop { display: none; }
.content { flex: 1; min-width: 0; padding: 28px 34px; }
.content h1 { font-family: var(--font-display); font-size: 1.8rem; font-weight: 500; line-height: 1.15; color: var(--color-tinta); margin: 6px 0 20px; }
.nombre-cliente { color: var(--color-oro-700); font-family: var(--font-display); font-size: 1.4rem; font-weight: 500; }
.sync-note { color: var(--color-tinta-2); font-size: .82rem; margin: -6px 0 20px; }

/* ---------- Sidebar (teal + acentos) ---------- */
.sidebar {
    width: 264px; flex-shrink: 0;
    background: linear-gradient(180deg, #1A444D 0%, #102e35 100%);
    color: var(--color-crema); display: flex; flex-direction: column;
}
.sidebar-client { padding: 26px 18px 20px; text-align: center; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-client .avatar {
    width: 58px; height: 58px; margin: 0 auto 12px; border-radius: 50%;
    background: linear-gradient(135deg, var(--color-oro-400), var(--color-oro-600));
    border: 2px solid rgba(213,229,231,0.35); color: #fff; font-weight: 600; font-size: 1.25rem;
    display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}
.sidebar-client .name { color: #fff; font-weight: 600; font-size: 1rem; line-height: 1.3; }
.sidebar-client .key { color: rgba(213,229,231,0.7); font-size: .8rem; margin-top: 4px; }
.sidebar-nav { padding: 14px 12px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 11px 13px;
    color: rgba(213,229,231,0.8); text-decoration: none; font-size: .855rem; font-weight: 500; line-height: 1.3;
    cursor: pointer; background: none; border: 0; width: 100%; text-align: left;
    border-radius: 10px; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-item.active {
    background: linear-gradient(90deg, rgba(79,133,141,0.35), rgba(79,133,141,0.15));
    color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--color-oro-300);
}
.nav-item .ico { width: 20px; height: 20px; flex-shrink: 0; opacity: .85; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-footer .ff-brand { color: #fff; font-weight: 600; font-size: .82rem; }
.sidebar-footer .ff-sub { color: rgba(213,229,231,0.6); font-size: .74rem; margin-top: 2px; }

/* ---------- Tarjetas ---------- */
.card {
    background: #fff; border: 1px solid var(--color-linea); border-radius: 14px;
    margin-bottom: 20px; overflow: hidden;
    box-shadow: 0 1px 2px rgba(28,43,47,.03), 0 8px 24px rgba(28,43,47,.04);
}
.card-header {
    padding: 15px 20px; border-bottom: 1px solid var(--color-linea);
    font-weight: 600; font-size: .95rem; color: var(--color-tinta);
    background: linear-gradient(180deg, #fbfdfd, #f4f9f9);
}
.card-body { padding: 20px; }

/* ---------- Tablas ---------- */
.card table { width: 100%; border-collapse: collapse; }
.card th, .card td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--color-linea); }
.card tbody tr:last-child th, .card tbody tr:last-child td { border-bottom: 0; }
.card th { font-weight: 500; color: var(--color-tinta-2); width: 52%; }
.card td { color: var(--color-tinta); }
.card thead th {
    width: auto; font-weight: 600; font-size: .72rem; letter-spacing: .4px; text-transform: uppercase;
    color: var(--color-tinta-2); background: linear-gradient(180deg, #fbfdfd, #eef5f5);
    border-bottom: 2px solid var(--color-linea);
}
/* Filas pendientes (rojo Pro Ley) */
.fila-pendiente th, .fila-pendiente td { background: #fbecea; color: var(--color-alerta); }
.fila-pendiente th { color: var(--color-alerta); }

/* ---------- Acordeón ---------- */
.accordion-item { border: 1px solid var(--color-linea); border-radius: 12px; margin-bottom: 10px; overflow: hidden; background: #fff; }
.accordion-head {
    width: 100%; text-align: left; background: #fff; border: 0; cursor: pointer;
    padding: 15px 17px; font-weight: 600; color: var(--color-tinta); font-size: .94rem;
    display: flex; justify-content: space-between; align-items: center; gap: 12px; transition: background .15s;
}
.accordion-head:hover { background: var(--color-marfil); }
.accordion-body { padding: 0 17px; max-height: 0; overflow: hidden; transition: max-height .28s ease, padding .28s ease; color: var(--color-tinta-2); font-size: .93rem; }
.accordion-item.open .accordion-body { padding: 2px 17px 17px; max-height: 2000px; }
.accordion-head .chev { color: var(--color-oro-500); transition: transform .2s; flex: none; }
.accordion-item.open .accordion-head .chev { transform: rotate(180deg); }

/* ---------- Guías, notas, subida ---------- */
.guide-img { max-width: 100%; border-radius: 10px; border: 1px solid var(--color-linea); display: block; }
.upload-box { text-align: center; padding: 6px 0; }
.notas { margin: 16px 0 0; padding-left: 18px; font-size: .9rem; color: var(--color-tinta-2); }
.notas li { margin-bottom: 9px; }
.notas .rojo { color: var(--color-alerta); font-weight: 600; }

/* ---------- Tabs (secciones conmutadas por JS) ---------- */
.tab.hidden { display: none; }

/* ---------- Login / tarjeta centrada ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
    background: linear-gradient(160deg, #1A444D 0%, #102e35 100%); }
.auth-card { background: #fff; border-radius: 18px; padding: 34px 30px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-card h1 { font-family: var(--font-display); font-size: 1.5rem; margin: 4px 0 2px; color: var(--color-oro-700); }
.auth-card .sub { font-size: .86rem; color: var(--color-tinta-2); margin: 0 0 20px; }
.auth-logo { width: 46px; height: 46px; border-radius: 12px; background: var(--color-oro-700); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-family: var(--font-display); margin-bottom: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
    .sidebar-toggle { display: inline-flex; }
    .layout { display: block; }
    .sidebar { position: fixed; top: 64px; left: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform .25s ease; z-index: 50; }
    body.sidebar-open .sidebar { transform: translateX(0); box-shadow: 4px 0 26px rgba(0,0,0,.35); }
    .sidebar-backdrop { position: fixed; top: 64px; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.5); opacity: 0; visibility: hidden; transition: opacity .25s; z-index: 40; }
    body.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }
    .content { padding: 20px 18px; }
}
@media (max-width: 520px) {
    .topbar { padding: 0 14px; }
    .topbar .llave { display: none; }
    .content { padding: 16px 14px; }
    .content h1 { font-size: 1.5rem; }
    .card th, .card td { padding: 9px 11px; }
}
