/* ============================================================
   ESTILOS GLOBALES - EHCi Web
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

:root {
    --azul-noche: #1E2B3E;
    --naranja:    #F27405;
    --coral:      #E55249;
    --crema:      #F4F7F6;
    --blanco:     #FFFFFF;
    --header-h:   70px;
    --shadow-sm:  0 2px 8px rgba(0,0,0,.06);
    --shadow-md:  0 4px 16px rgba(0,0,0,.09);
    --shadow-lg:  0 10px 32px rgba(0,0,0,.13);
    --radius:     12px;
    --transition: .22s ease;

    /* Espaciado fluido */
    --space-xs:  clamp(.4rem,  1vw,  .6rem);
    --space-sm:  clamp(.75rem, 2vw,  1rem);
    --space-md:  clamp(1rem,   3vw,  1.5rem);
    --space-lg:  clamp(1.5rem, 4vw,  2.5rem);
    --space-xl:  clamp(2rem,   6vw,  4rem);
}

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--crema);
    color: #333;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a   { color: inherit; }
h1, h2, h3, h4, h5 { line-height: 1.25; }

/* ── Utilidades ─────────────────────────────────────────── */
.container   { max-width: 1200px; margin: 0 auto; padding: 0 5%; }
.text-center { text-align: center; }
.mt-auto     { margin-top: auto; }

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--azul-noche); }

/* ── Inputs globales ─────────────────────────────────────── */
input, select, textarea, button { font-family: inherit; }

/* Todos los inputs de tipo texto respetan ancho del contenedor */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="url"],
select,
textarea {
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
}

/* ── Skip link (accesibilidad) ───────────────────────────── */
.skip-link {
    position: absolute; top: -40px; left: 6px;
    background: var(--coral); color: #fff;
    padding: 8px 14px; border-radius: 0 0 6px 6px;
    font-weight: 700; text-decoration: none;
    transition: top .2s; z-index: 9999;
}
.skip-link:focus { top: 0; }

/* ── Animación fade-in ───────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
main { animation: fadeIn .35s ease both; }

/* ── Helpers responsive ──────────────────────────────────── */
@media (max-width: 768px)  { .oculto-movil   { display: none !important; } }
@media (min-width: 769px)  { .solo-movil     { display: none !important; } }
@media (max-width: 1024px) { .oculto-tablet  { display: none !important; } }

/* ── Botones globales ────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: .65em 1.4em;
    border-radius: 7px;
    font-weight: 700;
    font-size: .95rem;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background var(--transition), transform var(--transition);
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--coral);      color: #fff; }
.btn-primary:hover { background: #c93f37; }
.btn-secondary { background: var(--azul-noche); color: #fff; }
.btn-secondary:hover { background: #162030; }
.btn-naranja   { background: var(--naranja);    color: #fff; }
.btn-naranja:hover { background: #d96600; }
.btn-outline   { background: transparent; border: 2px solid currentColor; }

/* En móvil los botones ocupan todo el ancho por defecto
   cuando están solos en su contenedor */
@media (max-width: 480px) {
    .btn-full-mobile { width: 100%; text-align: center; }
}

/* ── Tarjetas globales ───────────────────────────────────── */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* ── Formularios globales ────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: .88rem;
    color: #333;
    margin-bottom: .4em;
}
.form-input {
    width: 100%;
    padding: .65em .9em;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: .97rem;
    transition: border-color var(--transition);
    box-sizing: border-box;
}
.form-input:focus {
    border-color: var(--coral);
    outline: none;
    box-shadow: 0 0 0 3px rgba(229,82,73,.12);
}
textarea.form-input { resize: vertical; min-height: 110px; }

/* Leyenda de campo obligatorio */
.leyenda-oblig {
    font-size: .75rem;
    color: #888;
    margin: -.25rem 0 1rem;
}
.leyenda-oblig .req,
.req { color: var(--coral); font-weight: 700; }

/* ── Grids de formulario ─────────────────────────────────── */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .9rem 1.2rem;
}
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .9rem 1.2rem;
}
.form-grid-2 .span2,
.form-grid-3 .span3 { grid-column: 1 / -1; }

@media (max-width: 600px) {
    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }
    .form-grid-2 .span2,
    .form-grid-3 .span3 { grid-column: 1; }
}

/* ── Tablas responsive ───────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabla-adm {
    width: 100%;
    border-collapse: collapse;
    min-width: 480px;
}
.tabla-adm th, .tabla-adm td {
    padding: .75em 1em;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
    font-size: .9rem;
}
.tabla-adm thead tr { background: var(--azul-noche); color: #fff; }
.tabla-adm tbody tr:hover { background: #fafafa; }

/* ── Badges / etiquetas ──────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .2em .65em;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 700;
    color: #fff;
}
.badge-azul    { background: #3498db; }
.badge-verde   { background: #27ae60; }
.badge-naranja { background: var(--naranja); }
.badge-coral   { background: var(--coral); }
.badge-gris    { background: #95a5a6; }
.badge-morado  { background: #9b59b6; }

/* Nivel de usuario */
.nivel-badge { display: inline-block; padding: .2em .75em; border-radius: 20px; font-size: .75rem; font-weight: 700; }
.nivel-1 { background: #e3f2fd; color: #1565c0; }
.nivel-2 { background: #fff3e0; color: #e65100; }
.nivel-3 { background: #fce4ec; color: #880e4f; }

/* ── Botones de acción en tablas ─────────────────────────── */
.btn-accion {
    display: inline-block;
    padding: .3em .8em;
    border-radius: 5px;
    font-size: .78rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: opacity var(--transition);
    white-space: nowrap;
}
.btn-accion:hover { opacity: .82; }
.btn-green  { background: #27ae60; color: #fff; }
.btn-red    { background: var(--coral); color: #fff; }
.btn-blue   { background: #3498db; color: #fff; }
.btn-gray   { background: #bbb; color: #fff; cursor: default; }
.btn-guardar {
    width: 100%;
    background: var(--azul-noche);
    color: #fff;
    padding: .8em;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background var(--transition);
    margin-top: .5rem;
}
.btn-guardar:hover { background: var(--coral); }

/* ── Título de sección admin ─────────────────────────────── */
.seccion-titulo {
    font-size: clamp(1.1rem, 3vw, 1.4rem);
    color: var(--azul-noche);
    border-left: 4px solid var(--coral);
    padding-left: .75em;
    margin: 1.8rem 0 1rem;
}

/* ── Cards de panel admin ────────────────────────────────── */
.form-card {
    background: #fff;
    border-radius: var(--radius);
    padding: clamp(16px, 4vw, 28px);
    box-shadow: var(--shadow-sm);
}

/* ── Flash messages ──────────────────────────────────────── */
.flash {
    padding: .85em 1.2em;
    border-radius: 8px;
    margin: 1rem 5%;
    font-size: .95rem;
    font-weight: 500;
}
.flash--exito { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash--error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.flash--info  { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ── Paginación ──────────────────────────────────────────── */
.paginacion { margin: 2.5rem 0 1.25rem; text-align: center; }
.paginacion__lista {
    display: inline-flex;
    gap: 5px;
    list-style: none;
    padding: 0; margin: 0 0 .6rem;
    flex-wrap: wrap;
    justify-content: center;
}
.paginacion__btn {
    display: inline-block;
    padding: .5em .9em;
    border-radius: 6px;
    background: #fff;
    color: var(--azul-noche);
    text-decoration: none;
    border: 1px solid #ddd;
    font-weight: 600;
    font-size: .88rem;
    transition: .2s;
    min-width: 36px;
    text-align: center;
}
.paginacion__btn:hover       { background: var(--naranja); color: #fff; border-color: var(--naranja); }
.paginacion__btn--activo     { background: var(--azul-noche); color: #fff; border-color: var(--azul-noche); pointer-events: none; }
.paginacion__btn--disabled   { background: #f5f5f5; color: #aaa; border-color: #eee; pointer-events: none; }
.paginacion__elipsis         { display: inline-block; padding: .5em .4em; color: #999; }
.paginacion__info            { font-size: .8rem; color: #888; margin: 0; }

/* ── Botón flotante WhatsApp ─────────────────────────────── */
.btn-wa {
    position: fixed;
    bottom: 24px; right: 24px;
    background: #25D366;
    border-radius: 50%;
    width: 56px; height: 56px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 14px rgba(0,0,0,.25);
    z-index: 999;
    text-decoration: none;
    transition: transform .2s;
}
.btn-wa:hover { transform: scale(1.1); }
.btn-wa img   { width: 32px; height: 32px; }

/* ── Modal overlay genérico ──────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 9000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: #fff;
    border-radius: var(--radius);
    padding: clamp(20px, 5vw, 32px);
    width: 100%;
    max-width: 720px;
    position: relative;
    box-shadow: var(--shadow-lg);
    margin: auto;
}
.modal-close {
    position: absolute; top: 14px; right: 16px;
    background: none; border: none;
    font-size: 1.4rem; cursor: pointer; color: #888;
    line-height: 1;
}
.modal-box h3 { color: var(--azul-noche); margin: 0 0 .6rem; }

/* ── Grid del modal (2 columnas) ─────────────────────────── */
.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .85rem 1.2rem;
    align-items: start;
}
.modal-grid .span2 { grid-column: 1 / -1; }

@media (max-width: 600px) {
    .modal-grid { grid-template-columns: 1fr; }
    .modal-grid .span2 { grid-column: 1; }
    .modal-box { padding: 18px; }
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE GLOBAL
   Breakpoints: 480px | 600px | 768px | 1024px
   ════════════════════════════════════════════════════════════ */

/* ── Tablet grande y escritorio pequeño ─── (≤1024px) ──── */
@media (max-width: 1024px) {
    .container { padding: 0 4%; }
}

/* ── Tablet ──────────────────────────────── (≤768px) ───── */
@media (max-width: 768px) {
    :root { --header-h: 60px; }

    /* Reducir padding de main en tablet */
    main { padding-left: 0 !important; padding-right: 0 !important; }

    /* Formularios: una columna */
    .form-grid-2,
    .form-grid-3,
    .form-grid {
        grid-template-columns: 1fr !important;
    }
    .form-grid .span2,
    .form-grid-2 .span2,
    .form-grid-3 .span3 { grid-column: 1 !important; }

    /* Tablas con scroll horizontal */
    table { display: block; overflow-x: auto; }

    /* Cards admin a una columna */
    .adm-grid  { grid-template-columns: 1fr !important; }
    .admin-container { grid-template-columns: 1fr !important; }

    /* Perfil */
    .perfil-container { margin: 16px !important; padding: 20px !important; }

    /* Registro */
    .registro-container { margin: 16px !important; padding: 20px !important; }

    /* Botón donar flotante */
    .btn-donar-flotante {
        padding: 14px !important;
        left: 12px !important;
        bottom: 12px !important;
        border-radius: 50% !important;
    }
    .texto-donar { display: none !important; }

    /* WhatsApp flotante */
    .btn-wa,
    .whatsapp-float {
        width: 48px !important; height: 48px !important;
        bottom: 14px !important; right: 14px !important;
    }
    .whatsapp-float img,
    .btn-wa img { width: 27px !important; }

    /* Footer a una columna */
    footer > div > div { text-align: center !important; }

    /* Contacto */
    .contacto-grid { grid-template-columns: 1fr !important; }
}

/* ── Móvil grande ────────────────────────── (≤600px) ───── */
@media (max-width: 600px) {
    body { font-size: 15px; }

    h1 { font-size: clamp(1.4rem, 6vw, 2rem); }
    h2 { font-size: clamp(1.2rem, 5vw, 1.6rem); }
    h3 { font-size: clamp(1rem,  4vw, 1.3rem); }

    /* Acciones en tabla: apilar verticalmente si no caben */
    .btn-accion { font-size: .72rem; padding: .25em .6em; }

    /* Flash messages sin margen lateral */
    .flash { margin: .75rem 0; border-radius: 0; }

    /* Secciones con padding lateral consistente */
    section, .adm-page { padding-left: 4% !important; padding-right: 4% !important; }
}

/* ── Móvil pequeño ───────────────────────── (≤480px) ───── */
@media (max-width: 480px) {
    /* Nav con más espacio */
    .nav-menu a { font-size: 1.05rem !important; padding: 16px 0 !important; }

    /* Paginación más compacta */
    .paginacion__btn { padding: .4em .7em; font-size: .82rem; min-width: 32px; }

    /* Modal a pantalla completa */
    .modal-box { max-width: 100%; border-radius: 0; min-height: auto; }
    .modal-overlay { padding: 0; align-items: flex-start; }

    /* Campos de formulario más altos para touch */
    .form-input,
    input[type="text"], input[type="email"],
    input[type="password"], input[type="tel"],
    input[type="number"], input[type="date"],
    select { padding: .8em 1em; font-size: 1rem; }

    /* Botones táctiles */
    button[type="submit"], .btn-save, .btn-guardar, .btn-crear {
        padding: .9em 1em !important;
        font-size: 1rem !important;
        min-height: 48px;
    }

    /* Grids de opciones (checkboxes) */
    .opciones-box { flex-direction: column; gap: 12px; }

    /* Tabla admin: ocultar columnas secundarias */
    .tabla-adm th:nth-child(4),
    .tabla-adm td:nth-child(4) { display: none; }
}
