/* ═══════════════════════════════════════════════════════════
   style.css — Sistema de Ficha Médica Escolar
   Estilos globales para index.php / formulario.php
═══════════════════════════════════════════════════════════ */

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

:root {
    --g950: #052e16;
    --g900: #14532d;
    --g800: #166534;
    --g700: #15803d;
    --g600: #16a34a;
    --g500: #22c55e;
    --g400: #4ade80;
    --g100: #dcfce7;
    --g50: #f0fdf4;
    --s900: #0f172a;
    --s800: #1e293b;
    --s700: #334155;
    --s600: #475569;
    --s500: #64748b;
    --s400: #94a3b8;
    --s300: #cbd5e1;
    --s200: #e2e8f0;
    --s100: #f1f5f9;
    --s50: #f8fafc;
    --white: #ffffff;
    --amber: #d97706;
    --amber-bg: #fffbeb;
    --amber-border: #fcd34d;
}

html {
    scroll-behavior: smooth;
    height: 100%;
}

/* ── Fix footer sticky-bottom: el body es un flex column ── */
body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--s100);
    color: var(--s700);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Clase hidden para la lógica de toggle */
.hidden {
    display: none !important;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--s100);
}

::-webkit-scrollbar-thumb {
    background: var(--s300);
    border-radius: 99px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--s400);
}

/* ── Animaciones ── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.4s ease-out forwards;
}

/* ═══════════ HEADER ═══════════ */
.site-header {
    background: linear-gradient(135deg, var(--g950) 0%, var(--g900) 50%, var(--g800) 100%);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 20px rgba(0, 0, 0, .25);
    flex-shrink: 0;
}

.header-image-wrap {
    max-width: 860px;
    margin: 0 auto;
}

.header-image-wrap img {
    width: 100%;
    max-height: 110px;
    object-fit: contain;
    display: block;
}

.header-bar {
    background: rgba(0, 0, 0, .2);
    backdrop-filter: blur(8px);
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.header-bar-inner {
    max-width: 860px;
    margin: 0 auto;
    padding: .6rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.header-title {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--white);
    letter-spacing: -.01em;
}

.header-title-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, .12);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.header-title-icon svg {
    width: 18px;
    height: 18px;
    stroke: white;
}

.badge-edit {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    background: #d97706;
    color: white;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: .25rem .65rem;
    border-radius: 99px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-shrink: 0;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 99px;
    padding: .35rem .75rem;
}

.user-chip svg {
    width: 15px;
    height: 15px;
    stroke: rgba(255, 255, 255, .7);
    flex-shrink: 0;
}

.user-chip-name {
    font-size: .75rem;
    font-weight: 500;
    color: white;
    white-space: nowrap;
}

.user-chip-role {
    font-size: .7rem;
    color: rgba(255, 255, 255, .55);
    border-left: 1px solid rgba(255, 255, 255, .2);
    padding-left: .5rem;
    white-space: nowrap;
}

.btn-header {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .85rem;
    border-radius: 8px;
    font-size: .75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, .15);
    background: rgba(255, 255, 255, .08);
    color: white;
}

.btn-header:hover {
    background: rgba(255, 255, 255, .18);
}

.btn-header--danger:hover {
    background: rgba(220, 38, 38, .7);
    border-color: transparent;
}

.btn-header svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
}

/* ═══════════ LAYOUT PRINCIPAL ═══════════ */
/* flex:1 hace que el <main> ocupe todo el espacio disponible
   empujando el footer siempre al fondo, incluso con secciones contraídas */
.page-main {
    flex: 1;
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
    padding: 1.75rem 1.25rem 0rem;
}

/* ═══════════ CAMPOS DEL FORMULARIO ═══════════ */
.field-label {
    display: block;
    font-size: .775rem;
    font-weight: 600;
    color: var(--s700);
    margin-bottom: .4rem;
    letter-spacing: .01em;
}

.field-label .req {
    color: #ef4444;
    margin-left: 2px;
}

.field-input {
    width: 100%;
    padding: .7rem .95rem;
    background: var(--s50);
    border: 1.5px solid var(--s200);
    border-radius: 9px;
    font-family: inherit;
    font-size: .855rem;
    color: var(--s900);
    transition: border-color .2s, box-shadow .2s, background .2s;
    outline: none;
    appearance: none;
}

.field-input::placeholder {
    color: var(--s400);
}

.field-input:focus {
    border-color: var(--g500);
    background: white;
    box-shadow: 0 0 0 3.5px rgba(34, 197, 94, .14);
}

.field-input[readonly],
.field-input[readonly]:focus {
    background: var(--s100);
    border-color: var(--s200);
    cursor: not-allowed;
    box-shadow: none;
    color: var(--s500);
}

textarea.field-input {
    resize: vertical;
    min-height: 70px;
    line-height: 1.5;
}

select.field-input {
    cursor: pointer;
}

/* Select con flecha */
.select-wrap {
    position: relative;
}

.select-wrap::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--s400);
    pointer-events: none;
}

/* ═══════════ SECCIONES DEL FORM ═══════════ */
.form-section {
    background: var(--white);
    border: 1px solid var(--s200);
    border-radius: 14px;
    overflow: hidden;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .05);
    animation: fadeInUp .35s ease-out both;
}

.form-section:nth-child(1) {
    animation-delay: .05s;
}

.form-section:nth-child(2) {
    animation-delay: .10s;
}

.form-section:nth-child(3) {
    animation-delay: .15s;
}

.form-section:nth-child(4) {
    animation-delay: .20s;
}

.form-section:nth-child(5) {
    animation-delay: .25s;
}

.section-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1rem 1.35rem;
    background: linear-gradient(135deg, var(--g800) 0%, var(--g700) 100%);
    cursor: pointer;
    user-select: none;
}

.section-header-icon {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, .15);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.section-header-icon svg {
    width: 19px;
    height: 19px;
    stroke: white;
}

.section-header-title {
    font-size: .95rem;
    font-weight: 700;
    color: white;
    letter-spacing: -.01em;
    flex: 1;
}

.section-header-arrow {
    width: 22px;
    height: 22px;
    stroke: rgba(255, 255, 255, .7);
    transition: transform .3s;
    flex-shrink: 0;
}

.section-header.collapsed .section-header-arrow {
    transform: rotate(-90deg);
}

.section-body {
    padding: 1.35rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.section-body.collapsed {
    display: none;
}

.col-span-2 {
    grid-column: span 2;
}

/* ═══════════ CAMPOS CONDICIONALES ═══════════ */
.cond-field {
    background: linear-gradient(135deg, var(--g50), white);
    border: 1.5px solid #bbf7d0;
    border-radius: 10px;
    padding: .85rem;
    animation: slideDown .25s ease-out;
}

.cond-field .field-label {
    color: var(--g700);
}

/* ═══════════ BOTÓN GUARDAR ═══════════ */
.btn-save-wrap {
    display: flex;
    justify-content: center;
    padding: .5rem 0 1rem;
}

.btn-save {
    display: inline-flex;
    align-items: center;
    gap: .65rem;
    padding: .95rem 2.5rem;
    background: linear-gradient(135deg, var(--g800) 0%, var(--g600) 100%);
    color: white;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 700;
    letter-spacing: .01em;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(22, 163, 74, .35);
    transition: transform .2s, box-shadow .2s, filter .2s;
    position: relative;
    overflow: hidden;
}

.btn-save::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, .12), transparent 60%);
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(22, 163, 74, .45);
    filter: brightness(1.06);
}

.btn-save:active {
    transform: translateY(0);
}

.btn-save svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

/* ═══════════ FOOTER ═══════════ */
.site-footer {
    background: var(--g950);
    color: rgba(255, 255, 255, .4);
    text-align: center;
    padding: 1rem;
    font-size: .75rem;
    flex-shrink: 0;
}

/* ═══════════ MODALES ═══════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-box {
    background: white;
    border-radius: 18px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, .25);
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeInUp .3s ease-out;
}

.modal-box--lg {
    max-width: 680px;
    max-height: 88vh;
}

.modal-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.1rem 1.4rem;
}

.modal-header--green {
    background: linear-gradient(135deg, var(--g800), var(--g600));
}

.modal-header--red {
    background: linear-gradient(135deg, #b91c1c, #ef4444);
}

.modal-header--amber {
    background: linear-gradient(135deg, #92400e, #d97706);
}

.modal-header--orange {
    background: linear-gradient(135deg, #c2410c, #f97316);
}

.modal-header-icon {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, .15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.modal-header-icon svg {
    width: 20px;
    height: 20px;
    stroke: white;
}

.modal-header-title {
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.modal-header-sub {
    font-size: .75rem;
    color: rgba(255, 255, 255, .7);
    margin-top: .1rem;
}

.modal-body {
    padding: 1.6rem 1.8rem;
    overflow-y: auto;
    flex: 1;
    background: #f8fafc;
}

.modal-desc {
    font-size: .92rem;
    color: var(--s600);
    line-height: 1.75;
    margin: 0;
    padding: .75rem 1rem;
    background: white;
    border: 1px solid var(--s200);
    border-radius: 10px;
}

.modal-desc strong {
    color: var(--s800);
    font-weight: 700;
}

.modal-icon-wrap,
.modal-title {
    display: none;
}

/* heredadas — no usadas */

.modal-footer {
    padding: 1rem 1.4rem;
    border-top: 1px solid var(--s200);
    background: white;
    display: flex;
    gap: .75rem;
}

.btn-modal {
    flex: 1;
    padding: .75rem 1rem;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: .855rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    transition: all .2s;
}

.btn-modal svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
}

.btn-modal--green {
    background: var(--g600);
    color: white;
}

.btn-modal--green:hover {
    background: var(--g700);
}

.btn-modal--red {
    background: #ef4444;
    color: white;
}

.btn-modal--red:hover {
    background: #dc2626;
}

.btn-modal--amber {
    background: #d97706;
    color: white;
}

.btn-modal--amber:hover {
    background: #b45309;
}

.btn-modal--orange {
    background: #ea580c;
    color: white;
}

.btn-modal--orange:hover {
    background: #c2410c;
}

.btn-modal--gray {
    background: var(--s200);
    color: var(--s700);
}

.btn-modal--gray:hover {
    background: var(--s300);
}

/* Resumen modal */
.resumen-section {
    margin-bottom: 1.1rem;
}

.resumen-section-title {
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--g700);
    padding: .4rem .6rem;
    background: var(--g50);
    border-radius: 6px;
    margin-bottom: .6rem;
}

.resumen-row {
    display: flex;
    gap: .5rem;
    padding: .35rem .5rem;
    border-radius: 6px;
    font-size: .825rem;
}

.resumen-row:nth-child(even) {
    background: var(--s50);
}

.resumen-key {
    color: var(--s500);
    min-width: 160px;
    flex-shrink: 0;
}

.resumen-val {
    color: var(--s800);
    font-weight: 500;
}

/* Validación modal */
.val-item {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .55rem .65rem;
    border-radius: 8px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    font-size: .825rem;
    color: #b91c1c;
}

.val-item svg {
    width: 16px;
    height: 16px;
    stroke: #ef4444;
    flex-shrink: 0;
    margin-top: 1px;
}

/* ═══════════ RESPONSIVE ═══════════ */
@media (max-width: 640px) {
    .section-body {
        grid-template-columns: 1fr;
    }

    .col-span-2 {
        grid-column: span 1;
    }

    .user-chip-role {
        display: none;
    }

    .modal-box--lg {
        max-height: 92vh;
    }
}

@media (max-width: 400px) {
    .header-bar-inner {
        flex-wrap: wrap;
    }

    .user-chip-name {
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ═══════════════════════════════════════════════════════════
   Compatibilidad con clases Tailwind inyectadas por scripts.js
   (HTML dinámico en #resumenContenido y #validacionContenido)
═══════════════════════════════════════════════════════════ */
.space-y-1\.5>*+* {
    margin-top: .375rem;
}

.space-y-1>*+* {
    margin-top: .25rem;
}

.space-y-2>*+* {
    margin-top: .5rem;
}

.flex {
    display: flex;
}

.inline-flex {
    display: inline-flex;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 {
    gap: .25rem;
}

.gap-2 {
    gap: .5rem;
}

.shrink-0 {
    flex-shrink: 0;
}

.w-4 {
    width: 1rem;
}

.h-4 {
    height: 1rem;
}

.mt-0\.5 {
    margin-top: .125rem;
}

.mb-1\.5 {
    margin-bottom: .375rem;
}

.mb-2 {
    margin-bottom: .5rem;
}

.mb-3 {
    margin-bottom: .75rem;
}

.mt-2 {
    margin-top: .5rem;
}

.pl-6 {
    padding-left: 1.5rem;
}

.px-2 {
    padding-left: .5rem;
    padding-right: .5rem;
}

.px-4 {
    padding-left: 1rem;
    padding-right: 1rem;
}

.py-0\.5 {
    padding-top: .125rem;
    padding-bottom: .125rem;
}

.py-1 {
    padding-top: .25rem;
    padding-bottom: .25rem;
}

.py-2\.5 {
    padding-top: .625rem;
    padding-bottom: .625rem;
}

.py-3 {
    padding-top: .75rem;
    padding-bottom: .75rem;
}

.p-3 {
    padding: .75rem;
}

.text-xs {
    font-size: .75rem;
    line-height: 1rem;
}

.text-sm {
    font-size: .875rem;
    line-height: 1.25rem;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.italic {
    font-style: italic;
}

.text-right {
    text-align: right;
}

.list-disc {
    list-style-type: disc;
}

.max-w-\[60\%\] {
    max-width: 60%;
}

.text-white {
    color: #fff;
}

.text-gray-400 {
    color: #9ca3af;
}

.text-gray-500 {
    color: #6b7280;
}

.text-gray-700 {
    color: #374151;
}

.text-gray-800 {
    color: #1f2937;
}

.text-gray-900 {
    color: #111827;
}

.text-amber-700 {
    color: #b45309;
}

.text-amber-800 {
    color: #92400e;
}

.text-red-500 {
    color: #ef4444;
}

.text-red-600 {
    color: #dc2626;
}

.text-red-700 {
    color: #b91c1c;
}

.text-red-800 {
    color: #991b1b;
}

.text-emerald-700 {
    color: #047857;
}

.bg-gray-50 {
    background-color: #f9fafb;
}

.bg-gray-100 {
    background-color: #f3f4f6;
}

.bg-amber-50 {
    background-color: #fffbeb;
}

.bg-amber-100 {
    background-color: #fef3c7;
}

.bg-red-50 {
    background-color: #fef2f2;
}

.bg-emerald-100 {
    background-color: #d1fae5;
}

.bg-primary-600 {
    background: linear-gradient(135deg, var(--g800), var(--g600));
}

.border {
    border-width: 1px;
    border-style: solid;
}

.border-b {
    border-bottom: 1px solid #e5e7eb;
}

.border-gray-100 {
    border-color: #f3f4f6;
}

.border-amber-200 {
    border-color: #fde68a;
}

.border-red-200 {
    border-color: #fecaca;
}

.last\:border-0:last-child {
    border: none;
}

.rounded-full {
    border-radius: 9999px;
}

.rounded-lg {
    border-radius: .5rem;
}

.rounded-xl {
    border-radius: .75rem;
}

.overflow-hidden {
    overflow: hidden;
}