/*=============================================================
   Archivo    : style.css
   Path       : /public/css/style.css
   Creado     : 2026-04-18
   Modificado : 2026-04-18
   Resumen    : Hoja de estilos principal de la webapp.
                Variables CSS, reset, layout, topbar, sidebar,
                formularios, botones, alertas, badges y
                utilidades. Diseño responsive mobile-first.
                - 2026-04-18: Creación. Fase 1.
============================================================= */

/* ══════════════════════════════════════════════════════════
   1. VARIABLES CSS (Design Tokens)
   ══════════════════════════════════════════════════════════ */
:root {
    /* ── Paleta principal ────────────────────────────────── */
    --color-bg:           #f0f2f7;        /* Fondo general */
    --color-surface:      #ffffff;        /* Tarjetas y paneles */
    --color-border:       #dde1ec;        /* Bordes suaves */
    --color-shadow:       rgba(30,40,80,.08);

    --color-primary:      #2c4ecb;        /* Azul institución */
    --color-primary-dark: #1e3a9e;
    --color-primary-light:#eef1fb;

    --color-danger:       #d63b3b;
    --color-warning:      #d48c1a;
    --color-success:      #2a9456;
    --color-info:         #1a7fb5;

    /* ── Texto ───────────────────────────────────────────── */
    --text-main:    #1a1e2e;
    --text-muted:   #6b7394;
    --text-inverse: #ffffff;

    /* ── Tipografía ──────────────────────────────────────── */
    --font-body:    'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --font-mono:    'Consolas', 'Courier New', monospace;
    --font-size-base: 15px;
    --line-height:  1.6;

    /* ── Layout ──────────────────────────────────────────── */
    --sidebar-width:     240px;
    --topbar-height:     56px;
    --content-max-width: 1200px;

    /* ── Espaciados ──────────────────────────────────────── */
    --sp-xs:  4px;
    --sp-sm:  8px;
    --sp-md:  16px;
    --sp-lg:  24px;
    --sp-xl:  40px;

    /* ── Bordes y sombras ────────────────────────────────── */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 4px var(--color-shadow);
    --shadow-md: 0 4px 16px var(--color-shadow);

    /* ── Transiciones ────────────────────────────────────── */
    --transition: .18s ease;
}


/* ══════════════════════════════════════════════════════════
   2. RESET Y BASE
   ══════════════════════════════════════════════════════════ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    color: var(--text-main);
    background-color: var(--color-bg);
    line-height: var(--line-height);
    min-height: 100vh;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--color-primary-dark); }

ul, ol { list-style: none; }

img { max-width: 100%; display: block; }

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}


/* ══════════════════════════════════════════════════════════
   3. TOPBAR (Barra superior)
   ══════════════════════════════════════════════════════════ */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--color-primary);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    padding: 0 var(--sp-md);
    gap: var(--sp-md);
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
}

/* Logo / nombre de la app */
.topbar__brand a {
    color: var(--text-inverse);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: .02em;
    white-space: nowrap;
}

/* Info del usuario (empuja a la derecha) */
.topbar__user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    flex-shrink: 0;
}

.topbar__user-name {
    font-size: .88rem;
    opacity: .9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.topbar__logout {
    color: rgba(255,255,255,.75);
    font-size: .82rem;
    padding: var(--sp-xs) var(--sp-sm);
    border: 1px solid rgba(255,255,255,.35);
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    white-space: nowrap;
}
.topbar__logout:hover {
    background: rgba(255,255,255,.15);
    color: #fff;
}

/* Botón hamburguesa (solo visible en móvil) */
.topbar__hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--sp-xs);
    flex-shrink: 0;
}
.topbar__hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: var(--transition);
}


/* ══════════════════════════════════════════════════════════
   4. LAYOUT PRINCIPAL (Sidebar + Contenido)
   ══════════════════════════════════════════════════════════ */
.layout {
    display: flex;
    min-height: 100vh;
    padding-top: var(--topbar-height);
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform var(--transition);
    z-index: 900;
}

.sidebar__menu {
    padding: var(--sp-md) 0;
    flex: 1;
}

.sidebar__item { }

.sidebar__link {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: 10px var(--sp-md);
    color: var(--text-main);
    font-size: .92rem;
    border-left: 3px solid transparent;
    transition: background var(--transition), border-color var(--transition);
}
.sidebar__link:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
    border-left-color: var(--color-primary);
}

.sidebar__item--active .sidebar__link {
    background: var(--color-primary-light);
    color: var(--color-primary);
    border-left-color: var(--color-primary);
    font-weight: 600;
}

.sidebar__item--danger .sidebar__link {
    color: var(--color-danger);
}
.sidebar__item--danger .sidebar__link:hover {
    background: #fdf0f0;
    border-left-color: var(--color-danger);
}

.sidebar__icon { font-style: normal; width: 20px; text-align: center; }
.sidebar__label { }

.sidebar__version {
    padding: var(--sp-sm) var(--sp-md);
    font-size: .75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--color-border);
    text-align: center;
}

/* ── Contenido principal ──────────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--sp-lg);
    max-width: var(--content-max-width);
    width: 100%;
}


/* ══════════════════════════════════════════════════════════
   5. CABECERA DE PÁGINA
   ══════════════════════════════════════════════════════════ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-lg);
    gap: var(--sp-md);
    flex-wrap: wrap;
}

.page-header__title {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-main);
}


/* ══════════════════════════════════════════════════════════
   6. TARJETAS (Cards)
   ══════════════════════════════════════════════════════════ */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--sp-lg);
    box-shadow: var(--shadow-sm);
}

/* Tarjeta de bienvenida del dashboard */
.welcome-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--sp-xl);
    box-shadow: var(--shadow-sm);
    max-width: 560px;
}
.welcome-card h3 {
    font-size: 1.25rem;
    margin-bottom: var(--sp-sm);
}
.welcome-card p { color: var(--text-muted); margin-bottom: var(--sp-sm); }
.welcome-card__info { font-size: .9rem; }


/* ══════════════════════════════════════════════════════════
   7. FORMULARIOS
   ══════════════════════════════════════════════════════════ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-xs);
    margin-bottom: var(--sp-md);
}

.form-label {
    font-size: .88rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px var(--sp-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--text-main);
    font-size: .95rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
    appearance: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(44,78,203,.12);
}
.form-input::placeholder { color: var(--text-muted); }

.form-textarea { resize: vertical; min-height: 100px; }

/* Mensaje de error bajo el campo */
.form-error {
    font-size: .8rem;
    color: var(--color-danger);
    margin-top: var(--sp-xs);
}


/* ══════════════════════════════════════════════════════════
   8. BOTONES
   ══════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-xs);
    padding: 10px var(--sp-lg);
    border: none;
    border-radius: var(--radius-sm);
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
    white-space: nowrap;
    text-decoration: none;
}
.btn:active { transform: translateY(1px); }

/* Variantes */
.btn--primary {
    background: var(--color-primary);
    color: #fff;
}
.btn--primary:hover {
    background: var(--color-primary-dark);
    color: #fff;
    box-shadow: 0 4px 12px rgba(44,78,203,.28);
}

.btn--secondary {
    background: var(--color-surface);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}
.btn--secondary:hover { background: var(--color-primary-light); }

.btn--danger {
    background: var(--color-danger);
    color: #fff;
}
.btn--danger:hover { background: #b83030; }

.btn--ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn--ghost:hover { background: var(--color-bg); color: var(--text-main); }

/* Modificadores */
.btn--full  { width: 100%; }
.btn--sm    { padding: 6px var(--sp-md); font-size: .83rem; }
.btn--lg    { padding: 13px var(--sp-xl); font-size: 1rem; }


/* ══════════════════════════════════════════════════════════
   9. ALERTAS
   ══════════════════════════════════════════════════════════ */
.alert {
    padding: var(--sp-sm) var(--sp-md);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    margin-bottom: var(--sp-md);
    border-left: 4px solid transparent;
}
.alert--error   { background: #fdf0f0; border-color: var(--color-danger);  color: #7a2020; }
.alert--success { background: #edfaf3; border-color: var(--color-success); color: #1a5c36; }
.alert--warning { background: #fdf6e3; border-color: var(--color-warning); color: #7a4d10; }
.alert--info    { background: #e8f4fb; border-color: var(--color-info);    color: #0e4d72; }


/* ══════════════════════════════════════════════════════════
   10. BADGES (etiquetas de rol y estado)
   ══════════════════════════════════════════════════════════ */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* Roles */
.badge--superadmin { background: #2a1060; color: #e0d0ff; }
.badge--admin      { background: #1e3a9e; color: #d4dfff; }
.badge--directora  { background: #1a5c36; color: #c6f0d8; }
.badge--profesor   { background: #7a4d10; color: #fde8c0; }

/* Estados de convenio */
.badge--vigente    { background: #c6f0d8; color: #1a5c36; }
.badge--caducado   { background: #fde8c0; color: #7a4d10; }
.badge--borrador   { background: #e2e5f0; color: #4a5080; }
.badge--renovacion { background: #fdf0f0; color: #7a2020; }


/* ══════════════════════════════════════════════════════════
   11. PÁGINA DE LOGIN
   ══════════════════════════════════════════════════════════ */
.login-page {
    background: var(--color-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--sp-md);
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-xl) var(--sp-xl);
    box-shadow: var(--shadow-md);
}

.login-card__header { text-align: center; margin-bottom: var(--sp-lg); }

.login-card__title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: var(--sp-xs);
}

.login-card__subtitle {
    font-size: .85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.login-form .btn--primary { margin-top: var(--sp-sm); }


/* ══════════════════════════════════════════════════════════
   12. PÁGINAS DE ERROR (403, 404)
   ══════════════════════════════════════════════════════════ */
.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: var(--sp-md);
    background: var(--color-bg);
}

.error-wrapper { width: 100%; max-width: 400px; }

.error-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-xl);
    text-align: center;
    box-shadow: var(--shadow-md);
}

.error-card__code {
    font-size: 4rem;
    font-weight: 900;
    color: var(--color-primary);
    line-height: 1;
    margin-bottom: var(--sp-sm);
}

.error-card__msg {
    color: var(--text-muted);
    margin-bottom: var(--sp-lg);
}


/* ══════════════════════════════════════════════════════════
   13. FOOTER
   ══════════════════════════════════════════════════════════ */
.footer {
    margin-left: var(--sidebar-width);
    padding: var(--sp-md) var(--sp-lg);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.footer__text {
    font-size: .78rem;
    color: var(--text-muted);
    text-align: center;
}


/* ══════════════════════════════════════════════════════════
   14. RESPONSIVE — MÓVIL (max-width: 768px)
   ══════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

    /* Mostrar botón hamburguesa */
    .topbar__hamburger { display: flex; }

    /* Ocultar nombre de usuario largo en móvil */
    .topbar__user-name { display: none; }

    /* Sidebar oculto por defecto, desliza desde la izquierda */
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.sidebar--open {
        transform: translateX(0);
        box-shadow: var(--shadow-md);
    }

    /* Contenido ocupa todo el ancho */
    .main-content {
        margin-left: 0;
        padding: var(--sp-md);
    }

    /* Footer sin margen del sidebar */
    .footer { margin-left: 0; }

    /* Tarjeta de login más compacta */
    .login-card { padding: var(--sp-lg) var(--sp-md); }

    /* Título de página más pequeño */
    .page-header__title { font-size: 1.2rem; }
}


/* ══════════════════════════════════════════════════════════
   15. OVERLAY (fondo oscuro al abrir sidebar en móvil)
   ══════════════════════════════════════════════════════════ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    z-index: 850;
}
.sidebar-overlay.sidebar-overlay--visible {
    display: block;
}


/* ══════════════════════════════════════════════════════════
   16. UTILIDADES
   ══════════════════════════════════════════════════════════ */
.text-muted  { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-sm  { margin-top: var(--sp-sm); }
.mt-md  { margin-top: var(--sp-md); }
.mt-lg  { margin-top: var(--sp-lg); }
.mb-md  { margin-bottom: var(--sp-md); }
.mb-lg  { margin-bottom: var(--sp-lg); }
.d-flex { display: flex; }
.gap-sm { gap: var(--sp-sm); }
.gap-md { gap: var(--sp-md); }
.flex-wrap { flex-wrap: wrap; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-100  { width: 100%; }
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0);
    white-space: nowrap; border: 0;
}
