@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

/* ==========================================================================
   1. VARIABLES DE ENTORNO
   ========================================================================== */
:root {
    --color-primary: #1a2a6c; 
    --color-accent: #b38e5d;  
    --color-danger: #e74c3c;
    --color-success: #27ae60;
    --color-white: #ffffff;
    --color-info-dark: #5a6a7a;
    --color-background: #f0f2f5;
    --color-dark: #2c3e50;
    --border-input: #cbd5e1;
    
    --box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    --card-border-radius: 1.2rem;
    --border-radius-1: 0.5rem;
    --border-radius-2: 0.8rem;

    /* Footer Gradiente */
    --footer-bg: linear-gradient(180deg, #052f91 0%, #020617 100%);
    --footer-text: #f8fafc;
    --light-muted-text: #94a3b8;
}

[data-theme="dark"] {
    --color-background: #0f172a;
    --color-white: #1e293b;
    --color-dark: #f8fafc;
    --color-info-dark: #94a3b8;
    --border-input: #334155;
    --box-shadow: 0 10px 35px rgba(0, 0, 0, 0.3);
    --footer-bg: linear-gradient(180deg, #0f172a 0%, #020617 100%);
}

/* ==========================================================================
   2. REINICIO Y MAQUETACIÓN GLOBAL
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-background);
    color: var(--color-dark);
    font-family: 'Poppins', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    width: 100%;
    max-width: 950px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

header.text-center {
    text-align: center;
    padding: 2.5rem 0 1.5rem 0;
}

.img-institucional {
    max-width: 240px;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.02));
}

/* ==========================================================================
   3. CONTENEDOR TIPO CARD PREMIUM
   ========================================================================== */
#contenedor {
    background: var(--color-white);
    padding: 3rem;
    border-radius: var(--card-border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 4rem;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

h4.text-center {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--color-primary);
    margin-bottom: 2rem;
    line-height: 1.3;
}
[data-theme="dark"] h4.text-center {
    color: var(--color-dark);
}

/* ==========================================================================
   4. TIPOGRAFÍA Y ENLACES
   ========================================================================== */
.text-justify {
    text-align: justify;
    line-height: 1.6;
}

.text-muted {
    color: var(--color-info-dark);
}

.small {
    font-size: 0.85rem;
}

.text-danger {
    color: var(--color-danger);
    font-weight: 600;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}
a:hover {
    text-decoration: underline;
}

[data-theme="dark"] a {
    color: #38bdf8;
}

hr {
    border: none;
    height: 1px;
    background-color: var(--border-input);
    margin: 2rem 0;
    opacity: 0.6;
}

h5.text-secondary {
    color: var(--color-accent);
    font-weight: 700;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-input);
    padding-bottom: 0.4rem;
    text-align: center;
}

/* ==========================================================================
   5. COMPONENTES DE ALERTA
   ========================================================================== */
.alert {
    padding: 1.2rem;
    border-radius: var(--border-radius-2);
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.alert-secondary {
    background-color: var(--color-background);
    border: 2px dashed var(--border-input);
}

/* ==========================================================================
   6. GRID DE FORMULARIO E INPUTS
   ========================================================================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 1.5rem;
}

.col-12 { grid-column: span 12; }
.col-6 { grid-column: span 6; }

@media (max-width: 768px) {
    .col-6 { grid-column: span 12; }
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-dark);
    margin-bottom: 0.5rem;
}

.form-control,
.form-select,
textarea {
    width: 100%;
    font-family: inherit;
    background-color: var(--color-white);
    color: var(--color-dark);
    border: 2px solid var(--border-input);
    border-radius: var(--border-radius-1);
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    height: 48px;
}

textarea {
    height: auto;
}

.form-control:focus,
.form-select:focus,
textarea:focus {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 4px rgba(26, 42, 108, 0.25) !important;
}

.form-check-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--color-success);
}

/* ==========================================================================
   7. BOTONES
   ========================================================================== */
.btn {
    font-family: inherit;
    padding: 0.7rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--border-radius-1);
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.btn-success {
    background-color: var(--color-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(26, 42, 108, 0.15);
}
.btn-success:hover {
    background-color: #121e4e;
    transform: translateY(-1px);
}

.btn-lg {
    padding: 0.9rem 2.5rem;
    font-size: 1rem;
}

.btn-center-container {
    text-align: center;
    margin-top: 2rem;
}

/* ==========================================================================
   8. SWITCH FLOTANTE Y SPINNER
   ========================================================================== */
.theme-switch {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 4000;
    cursor: pointer;
    background-color: var(--color-primary);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    transition: transform 0.2s, background-color 0.2s;
}

.theme-switch:hover {
    transform: scale(1.08);
}

.spinner-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: flex; justify-content: center; align-items: center;
    z-index: 9999; color: white; font-size: 2rem;
}

/* ==========================================================================
   9. FOOTER GRADIENTE PREMIUM
   ========================================================================== */
.pie-pagina {
    background: var(--footer-bg);
    color: var(--footer-text);
    margin-top: auto;
    border-top: 4px solid var(--color-accent);
    width: 100%;
}

.container-footer-wrap {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 0.8fr 1.2fr 1fr;
    gap: 50px;
    padding: 40px 0;
}

.brand-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.logo-footer-escudo {
    height: 80px;
    width: auto;
    object-fit: contain;
    margin-bottom: 12px;
}

.brand-column h5 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #ffffff;
}

.footer-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    position: relative;
    padding-bottom: 8px;
    color: #ffffff;
}

.footer-title::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; width: 35px; height: 3px;
    background-color: var(--color-accent);
    border-radius: 2px;
}

.footer-text-item {
    font-size: 0.9rem;
    margin-bottom: 14px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    line-height: 1.5;
    color: #cbd5e1;
}

.text-accent { color: var(--color-accent); }
.text-light-muted { color: var(--light-muted-text); }

.redes-container {
    display: flex;
    gap: 12px;
}

.redes-container a {
    color: var(--footer-text);
    background-color: rgba(255,255,255,0.06);
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}

.redes-container a:hover {
    background-color: var(--color-accent);
    transform: translateY(-3px);
    color: white;
}

.footer-copy {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 20px 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--light-muted-text);
}

@media screen and (max-width: 992px) {
    .footer-grid { grid-template-columns: 1fr; gap: 40px; text-align: center; }
    .footer-title { text-align: center; }
    .footer-title::after { left: 50%; transform: translateX(-50%); }
    .footer-text-item { justify-content: center; }
    .redes-container { justify-content: center; }
}

/* Modales Nativos */
dialog {
    margin: auto; border: none;
    border-radius: var(--card-border-radius);
    padding: 2rem; background: var(--color-white);
    color: var(--color-dark); box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    max-width: 500px; width: 90%;
}
dialog::backdrop {
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
}
.modal-header-native {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem;
}
.close-modal-btn {
    background: transparent; border: none; font-size: 1.5rem;
    cursor: pointer; color: var(--color-info-dark);
}