/* public/css/style.css - Instituto Monseñor Tavella Design System
   Estilo: gris carbón + naranja, tipografía geométrica pesada en mayúsculas
   con mucho interletrado, bloques planos y botones con contorno. */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap');

/* Tokens. Tema claro por defecto (theme.js lo aplica); oscuro como alternativa.
   --charcoal y --orange son la identidad y no cambian con el tema. */
:root {
    --charcoal: #333333;
    --charcoal-2: #2a2a2a;
    --charcoal-3: #1f1f1f;
    --orange: #f7931e;
    --orange-dark: #d9770a;
    --on-dark: #ffffff;
    --on-dark-muted: rgba(255, 255, 255, 0.62);

    --bg: #1c1c1c;
    --nav-bg: var(--charcoal);
    --surface: #262626;
    --surface-2: #303030;
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.28);
    --text: #f2f2f2;
    --text-muted: rgba(242, 242, 242, 0.66);
    --text-faint: rgba(242, 242, 242, 0.44);
    --shadow: rgba(0, 0, 0, 0.4);
    --accent: var(--orange);
    --gold: var(--orange);
    --danger: #ff6b5b;
    --success: #4cc38a;
}

:root[data-theme="light"] {
    --bg: #f1f1ef;
    --nav-bg: var(--charcoal);
    --surface: #ffffff;
    --surface-2: #f7f7f5;
    --border: rgba(51, 51, 51, 0.12);
    --border-strong: rgba(51, 51, 51, 0.32);
    --text: #333333;
    --text-muted: rgba(51, 51, 51, 0.68);
    --text-faint: rgba(51, 51, 51, 0.48);
    --shadow: rgba(51, 51, 51, 0.12);
    --accent: var(--orange-dark);
    --gold: var(--orange-dark);
    --danger: #c63b2b;
    --success: #2b7a4b;
}

/* ===== Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    overflow-x: hidden;
    transition: background-color .2s ease, color .2s ease;
}

h1, h2, h3, h4 {
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    line-height: 1.15;
}

h2 { font-size: clamp(1.4rem, 3.5vw, 2rem); }
h3 { font-size: 1.05rem; letter-spacing: 0.12em; }

a { color: inherit; text-decoration: none; transition: color .2s ease, opacity .2s ease; }
a:hover { opacity: 0.8; }

::selection { background: var(--orange); color: #fff; }

/* Título de sección con subrayado naranja */
.main-content > h2::after,
.portal-header h1::after {
    content: "";
    display: block;
    width: 56px;
    height: 4px;
    background: var(--orange);
    margin-top: 14px;
}

/* ===== Botones ===== */
.btn {
    display: inline-block;
    padding: 13px 36px;
    border: 2px solid var(--text);
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.btn:hover {
    background: var(--orange);
    border-color: var(--orange);
    color: #fff;
    opacity: 1;
}

.btn-primary,
button.btn[type="submit"] {
    background: var(--orange);
    border-color: var(--orange);
    color: #fff;
}

.btn-primary:hover,
button.btn[type="submit"]:hover {
    background: var(--charcoal);
    border-color: var(--charcoal);
}

/* ===== Tarjetas ===== */
.kits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0;
    width: 100%;
    margin-top: 32px;
}

.kit-card {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 32px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.kit-card h3 { font-size: 1.6rem; margin-top: 6px; }

/* Indicadores del dashboard: carbón / blanco / naranja, como una barra de bloques */
.stat-grid .kit-card { min-height: 150px; border: none !important; }
.stat-grid .kit-card p { letter-spacing: 0.22em; font-weight: 600; font-size: 0.68rem !important; }
.stat-grid .kit-card h3 { font-size: 3rem !important; font-weight: 900; letter-spacing: 0.02em; }
.stat-grid .kit-card:nth-child(1) {
    background: var(--charcoal);
    --text: #fff;
    --text-muted: var(--on-dark-muted);
    color: #fff;
}
.stat-grid .kit-card:nth-child(3) {
    background: var(--orange);
    --danger: #fff;
    --text-muted: rgba(255, 255, 255, 0.85);
    color: #fff;
}

/* ===== Formularios ===== */
.form-container { max-width: 600px; width: 100%; margin-top: 32px; }

.form-group { margin-bottom: 20px; text-align: left; }

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 14px 16px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-bottom: 2px solid var(--border-strong);
    color: var(--text);
    font-family: inherit;
    font-size: 0.92rem;
    transition: border-color .2s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-bottom-color: var(--orange);
}

/* ===== Tablas (admin y portal) ===== */
table th {
    font-size: 0.66rem !important;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.badge { border-radius: 0 !important; letter-spacing: 0.14em; }

/* ===== Navegación superior (portal del alumno) ===== */
.nav-logo img { height: 36px; width: auto; display: block; }

nav {
    position: fixed;
    top: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 56px;
    z-index: 1000;
    background: var(--charcoal);
    color: #fff;
    --text: #fff;
    --text-muted: var(--on-dark-muted);
    --danger: var(--orange);
    --border-strong: rgba(255, 255, 255, 0.3);
    --surface: transparent;
    --surface-2: rgba(255, 255, 255, 0.08);
}

nav .nav-logo { font-weight: 800 !important; letter-spacing: 0.25em !important; }

.logo { font-size: 1rem; font-weight: 800; letter-spacing: 0.25em; }

.nav-links { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }

.nav-links a {
    margin-left: 32px;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}

/* ===== Barra lateral (admin) ===== */
body .sidebar {
    background: var(--charcoal);
    border-right: none;
    color: #fff;
    --text: #fff;
    --text-muted: var(--on-dark-muted);
    --text-faint: rgba(255, 255, 255, 0.4);
    --danger: var(--orange);
    --border: rgba(255, 255, 255, 0.1);
    --border-strong: rgba(255, 255, 255, 0.3);
    --surface: transparent;
    --surface-2: rgba(255, 255, 255, 0.08);
}

body .sidebar .logo { font-size: 0.85rem; }
body .sidebar .nav-links { align-items: flex-start; }

body .sidebar .nav-links a {
    margin-left: 0;
    position: relative;
    font-size: 0.68rem;
    letter-spacing: 0.24em;
}

/* Enlace activo: el de la página actual se marca con color var(--text) en línea */
body .sidebar .nav-links a[style*="var(--text)"]::before {
    content: "";
    position: absolute;
    left: -40px;
    top: 50%;
    width: 24px;
    height: 3px;
    background: var(--orange);
    transform: translateY(-50%);
}

/* Texto vertical, como en la portada de referencia */
body .sidebar::after {
    content: "INSTITUTO MONSEÑOR TAVELLA  —  GESTIÓN DE CUOTAS";
    position: absolute;
    left: 14px;
    bottom: 40px;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.3em;
    color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
}

body .main-content { padding-top: 48px; }

/* ===== Botón de tema ===== */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-left: 20px;
    border: 1px solid var(--border-strong);
    border-radius: 0;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    flex-shrink: 0;
    transition: background .2s ease, border-color .2s ease;
}

.theme-toggle:hover { border-color: var(--orange); background: var(--surface-2); }
.theme-toggle:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

.nav-burger {
    display: none;
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-strong);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-size: 1.1rem;
}

/* ===== Portal del alumno ===== */
.portal-header h1 { font-weight: 900; letter-spacing: 0.06em !important; }

body .deuda-banner {
    background: var(--orange);
    border: none;
    color: #fff;
    --danger: #fff;
}

body .deuda-banner strong { font-size: 1.6rem !important; font-weight: 800; letter-spacing: 0.04em; }

body .info-card { background: var(--surface); }
body .info-value { font-weight: 700; }

body .btn-pagar {
    background: var(--charcoal);
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.18em;
    padding: 7px 16px;
}
body .btn-pagar:hover { background: var(--orange); }

body .btn-ver,
body .btn-guardar {
    border: 2px solid var(--accent);
    font-weight: 600;
}
body .btn-guardar:hover { background: var(--orange); border-color: var(--orange); color: #fff; }

/* ===== Login / registro ===== */
.auth-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 96px 1fr;
    background: var(--charcoal-3);
}

.auth-rail {
    background: var(--charcoal);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 28px 0 32px;
    color: #fff;
}

.auth-rail img { width: 40px; height: auto; }

.auth-rail .vertical {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    white-space: nowrap;
}

.auth-main {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    background:
        radial-gradient(circle at 78% 30%, rgba(247, 147, 30, 0.22), transparent 42%),
        linear-gradient(135deg, #3b3b3b 0%, #262626 55%, #1a1a1a 100%);
    color: #fff;
}

.auth-top {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 32px;
    padding: 28px 48px;
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    --text: #fff;
    --surface: transparent;
    --surface-2: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.35);
}

.auth-top .theme-toggle { margin-left: 0; }

.auth-hero {
    flex: 1;
    display: grid;
    grid-template-columns: 1.2fr minmax(300px, 400px);
    align-items: center;
    gap: 48px;
    padding: 24px 48px 48px;
}

.auth-title .eyebrow {
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-transform: uppercase;
}

.auth-title h1 {
    font-size: clamp(3rem, 9vw, 7rem);
    font-weight: 900;
    letter-spacing: 0.08em;
    line-height: 1;
    margin: 6px 0 22px;
}

.auth-title .lead {
    max-width: 420px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 0.95rem;
    margin-bottom: 30px;
}

.btn-outline-light {
    display: inline-block;
    padding: 12px 26px;
    border: 2px solid #fff;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.24em;
    text-transform: uppercase;
}
.btn-outline-light:hover { background: #fff; color: var(--charcoal); opacity: 1; }

.auth-card {
    background: var(--surface);
    color: var(--text);
    padding: clamp(24px, 4vw, 36px);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
    border-top: 5px solid var(--orange);
}

.auth-card h2 { font-size: 1.1rem; letter-spacing: 0.22em; margin-bottom: 26px; }
.auth-card .msg-error { color: var(--danger); font-size: 0.8rem; margin-bottom: 18px; }
.auth-card .msg-ok { color: var(--success); font-size: 0.8rem; margin-bottom: 18px; }
.auth-card .foot { margin-top: 22px; font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; text-align: center; color: var(--text-muted); }
.auth-card .foot a { color: var(--accent); font-weight: 600; }

.captcha-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.captcha-row img { border: 1px solid var(--border); height: 42px; width: 130px; display: block; }
.captcha-row button {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    font-size: 1.1rem;
    height: 42px;
    width: 42px;
}
.captcha-row button:hover { border-color: var(--orange); }

/* Barra inferior de bloques */
.auth-bar {
    display: grid;
    grid-template-columns: 96px 1.3fr 1fr 1fr;
    min-height: 88px;
}

.auth-bar > div { display: flex; align-items: center; gap: 16px; padding: 0 28px; }
.auth-bar .b-orange { background: var(--orange); color: #fff; justify-content: center; padding: 0; }
.auth-bar .b-dark { background: var(--charcoal); color: #fff; }
.auth-bar .b-light { background: #fff; color: var(--charcoal); justify-content: space-between; }
.auth-bar .b-cta { background: var(--orange); color: #fff; justify-content: space-between; }
.auth-bar strong { display: block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; }
.auth-bar small { display: block; font-size: 0.68rem; opacity: 0.75; }
.auth-bar .progress { flex: 1; height: 2px; background: rgba(255, 255, 255, 0.5); position: relative; }
.auth-bar .progress::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 45%; background: var(--orange); }
.auth-bar .chev { color: var(--orange); font-size: 1.6rem; font-weight: 300; }
.auth-bar svg { flex-shrink: 0; }

/* ===== Utilidades ===== */
.text-muted { color: var(--text-muted); }

.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ===== Responsive ===== */
@media (max-width: 1000px) {
    .auth-hero { grid-template-columns: 1fr; gap: 32px; padding: 16px 28px 40px; }
    .auth-top { padding: 22px 28px; gap: 20px; }
    .auth-bar { grid-template-columns: 1fr 1fr; }
    .auth-bar > div { min-height: 76px; }
    .auth-bar .b-orange, .auth-bar .b-dark { display: none; }
}

@media (max-width: 900px) {
    body .sidebar::after { display: none; }
    body .sidebar .nav-links a[style*="var(--text)"]::before { left: 0; top: auto; bottom: -6px; transform: none; }
    .stat-grid { grid-template-columns: 1fr !important; }
}

@media (max-width: 768px) {
    nav { padding: 14px 20px; }

    .nav-burger { display: inline-flex; align-items: center; justify-content: center; }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        background: var(--charcoal);
        border-top: 3px solid var(--orange);
        padding: 12px 20px 20px;
    }

    .nav-links.open { display: flex; }
    .nav-links a { margin-left: 0; padding: 10px 0; width: 100%; }
    .theme-toggle { margin-left: 0; }

    .auth-page { grid-template-columns: 1fr; }
    .auth-rail { display: none; }
    .auth-top { justify-content: space-between; padding: 16px; }
    .auth-top .brand { display: flex !important; }
    .auth-top .links { display: none; }
    .auth-hero { padding: 8px 16px 32px; }
    .auth-bar { grid-template-columns: 1fr; }
}

/* Bloques planos: anula los bordes redondeados heredados de estilos en línea */
.main-content .form-container,
.main-content input,
.main-content select,
.main-content textarea { border-radius: 0 !important; }

/* En celular el menú del admin no tiene botón hamburguesa: se muestra siempre en fila */
@media (max-width: 768px) {
    body .sidebar .nav-links {
        display: flex !important;
        position: static;
        flex-direction: row !important;
        flex-wrap: wrap;
        width: 100%;
        gap: 6px 20px;
        padding: 0;
        border: none;
        background: none;
    }
    body .sidebar .nav-links a { width: auto; padding: 6px 0; }
}

/* ===== Ayuda (botón "?" y panel lateral con guías paso a paso) ===== */
.ayuda-btn {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1500;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px 0 0;
    height: 52px;
    border: none;
    background: var(--orange);
    color: #fff;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
    transition: background .2s ease, transform .15s ease;
}
.ayuda-btn span {
    width: 52px;
    height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--charcoal);
    font-size: 1.5rem;
    font-weight: 900;
}
.ayuda-btn em { font-style: normal; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.22em; text-transform: uppercase; }
.ayuda-btn:hover { background: var(--orange-dark); transform: translateY(-2px); }
.ayuda-btn:focus-visible { outline: 3px solid var(--charcoal); outline-offset: 3px; }

/* Variante dentro de la barra superior (login) */
.ayuda-btn.ayuda-btn-inline { position: static; height: 36px; box-shadow: none; padding-right: 14px; }
.ayuda-btn.ayuda-btn-inline span { width: 36px; height: 36px; font-size: 1.05rem; background: rgba(0, 0, 0, 0.35); }

.ayuda-fondo { position: fixed; inset: 0; background: rgba(20, 20, 20, 0.55); z-index: 1600; }
.ayuda-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(460px, 100%);
    z-index: 1700;
    background: var(--surface);
    color: var(--text);
    display: flex;
    flex-direction: column;
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.3);
    animation: ayuda-entra .22s ease;
    text-align: left;
    letter-spacing: normal;
    text-transform: none;
}
@keyframes ayuda-entra { from { transform: translateX(40px); } to { transform: none; } }
.ayuda-panel[hidden], .ayuda-fondo[hidden] { display: none; }
.ayuda-panel header {
    background: var(--charcoal);
    color: #fff;
    padding: 22px 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    border-bottom: 4px solid var(--orange);
}
.ayuda-panel header small { font-size: 0.6rem; letter-spacing: 0.24em; text-transform: uppercase; opacity: 0.6; }
.ayuda-panel header h2 { font-size: 1.15rem; letter-spacing: 0.12em; margin-top: 4px; color: #fff; }
.ayuda-panel header h2::after { display: none; }
.ayuda-cerrar { background: none; border: 1px solid rgba(255, 255, 255, 0.35); color: #fff; width: 34px; height: 34px; cursor: pointer; font-size: 0.9rem; flex-shrink: 0; }
.ayuda-cerrar:hover { background: var(--orange); border-color: var(--orange); }
.ayuda-cuerpo { overflow-y: auto; padding: 18px 20px 28px; flex: 1; }
.ayuda-intro { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 12px; }
.ayuda-tema { border: 1px solid var(--border); margin-bottom: 8px; background: var(--surface-2); }
.ayuda-tema summary {
    cursor: pointer;
    list-style: none;
    padding: 14px 16px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.ayuda-tema summary::-webkit-details-marker { display: none; }
.ayuda-tema summary::after { content: "+"; font-size: 1.1rem; color: var(--orange); font-weight: 400; }
.ayuda-tema[open] summary { border-bottom: 1px solid var(--border); border-left: 4px solid var(--orange); padding-left: 12px; }
.ayuda-tema[open] summary::after { content: "−"; }
.ayuda-tema summary:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
.ayuda-tema ol { list-style: none; counter-reset: paso; padding: 12px 16px 16px; }
.ayuda-tema li {
    counter-increment: paso;
    position: relative;
    padding: 6px 0 6px 38px;
    font-size: 0.86rem;
    line-height: 1.55;
    color: var(--text);
}
.ayuda-tema li::before {
    content: counter(paso);
    position: absolute;
    left: 0;
    top: 6px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--charcoal);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
}
.ayuda-tema li b { font-weight: 700; }
.ayuda-pie { margin-top: 18px; font-size: 0.74rem; color: var(--text-faint); text-align: center; line-height: 1.6; }
body.ayuda-abierta { overflow: hidden; }

/* No tapar la barra de "pagar seleccionados" del portal */
.barra-pago { padding-right: 150px !important; }

@media (max-width: 600px) {
    .ayuda-btn { right: 14px; bottom: 14px; padding-right: 0; }
    .ayuda-btn em { display: none; }
    .ayuda-btn.ayuda-btn-inline em { display: none; }
    .barra-pago { padding-right: 80px !important; }
}

@media print {
    .ayuda-btn, .ayuda-panel, .ayuda-fondo { display: none !important; }
}

/* El panel de ayuda del login vive dentro de la barra superior, que redefine colores
   (fondo transparente, texto blanco): acá se le devuelven los colores del tema. */
.auth-top .ayuda-panel {
    --surface: #262626; --surface-2: #303030; --border: rgba(255, 255, 255, 0.1); --border-strong: rgba(255, 255, 255, 0.28);
    --text: #f2f2f2; --text-muted: rgba(242, 242, 242, 0.66); --text-faint: rgba(242, 242, 242, 0.44);
    font-size: 15px; font-weight: 400;
}
:root[data-theme="light"] .auth-top .ayuda-panel {
    --surface: #ffffff; --surface-2: #f7f7f5; --border: rgba(51, 51, 51, 0.12); --border-strong: rgba(51, 51, 51, 0.32);
    --text: #333333; --text-muted: rgba(51, 51, 51, 0.68); --text-faint: rgba(51, 51, 51, 0.48);
}
.ayuda-panel { background: var(--surface); opacity: 1; }
:root[data-theme="dark"] .ayuda-tema li::before { background: var(--orange); }
