/* =========================================================================
   PORTAL DE ESTUDIOS — OULTON
   Adaptado al sistema de diseño de "Turnos Online" (paleta: #316096 · #1F82AB
   · #11A5C1 · #00C4CF, tipografía Manrope/Inter, radios y sombras unificados)
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;700;800&family=Inter:wght@400;500;600;700&display=swap');

/* -------------------------------------------------------------------------
   1. TOKENS (heredados 1:1 del sistema de Turnos Online)
   ------------------------------------------------------------------------- */
:root {
    /* Paleta de marca */
    --brand-900: #1a3350;
    --brand-800: #234670;
    --brand-700: #316096;   /* dado */
    --brand-600: #276f9d;
    --brand-500: #1F82AB;   /* dado */
    --brand-400: #11A5C1;   /* dado */
    --brand-300: #00C4CF;   /* dado */
    --brand-200: #5cdbe0;
    --brand-100: #a8ecee;
    --brand-50:  #e7f8f9;

    --brand-900-rgb: 26, 51, 80;
    --brand-800-rgb: 35, 70, 112;
    --brand-700-rgb: 49, 96, 150;
    --brand-500-rgb: 31, 130, 171;
    --brand-400-rgb: 17, 165, 193;
    --brand-300-rgb: 0, 196, 207;

    /* Neutros con tinte azulado */
    --ink-900: #16212f;
    --ink-800: #223345;
    --ink-700: #3c4d5f;
    --ink-500: #6b7c8c;
    --ink-300: #a7b4c0;
    --ink-200: #ccd6de;
    --ink-100: #e3e9ed;
    --ink-50:  #f4f7f9;

    --surface: #ffffff;
    --surface-muted: #f5f9fb;

    /* Semánticos */
    --success: #16966b;
    --success-bg: #e3f6ee;
    --warning: #c98523;
    --warning-bg: #fbf0dc;
    --danger: #d1504d;
    --danger-bg: #fbe9e8;

    /* Radios y sombras */
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 2px 10px rgba(22, 51, 80, .07);
    --shadow-md: 0 10px 28px rgba(22, 51, 80, .10);
    --shadow-lg: 0 24px 56px rgba(22, 51, 80, .18);

    /* Tipografía */
    --font-display: 'Manrope', 'Segoe UI', sans-serif;
    --font-body: 'Inter', 'Segoe UI', sans-serif;

    --text-xs:   0.75rem;
    --text-sm:   0.875rem;
    --text-base: 1rem;
    --text-lg:   1.125rem;
    --text-xl:   1.25rem;

    --gradient-brand: linear-gradient(120deg, var(--brand-700) 0%, var(--brand-500) 38%, var(--brand-400) 70%, var(--brand-300) 100%);

    /* Alias específicos del Portal, mapeados a los tokens de marca
       (para no tener que reescribir cada selector que los use) */
    --color-primario: var(--brand-700);
    --color-primario-oscuro: var(--brand-800);
    --color-secundario: var(--brand-400);

    --color-sidebar: var(--brand-700);
    --color-sidebar-hover: var(--brand-800);
    --color-sidebar-activo: var(--brand-400);

    --color-fondo: var(--surface-muted);
    --color-texto: var(--ink-800);
    --color-texto-claro: var(--ink-500);
    --sidebar-ancho: 260px;
    --topbar-alto: 60px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--color-texto);
    background: var(--color-fondo);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--ink-900);
    font-weight: 700;
    letter-spacing: -0.01em;
}

::selection {
    background: var(--brand-200);
    color: var(--ink-900);
}

:focus-visible {
    outline: 2px solid var(--brand-400);
    outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   2. LOGIN
   ------------------------------------------------------------------------- */
body.bg-light {
    background: var(--color-fondo) !important;
    min-height: 100vh;
    font-family: var(--font-body);
    display: flex;
    flex-direction: column;
}

/* El login queda centrado y el footer se empuja al fondo de la pantalla */
body.bg-light .container {
    flex: 1;
}

.card-login-oulton {
    background-color: var(--surface);
    border: none;
    border-radius: var(--radius-lg);
    color: var(--ink-800);
    box-shadow: var(--shadow-lg);
}

.card-login-oulton .text-muted {
    color: var(--ink-500) !important;
}

.card-login-oulton .form-label {
    font-weight: 600;
    color: var(--ink-800);
    font-size: var(--text-sm);
}

.card-login-oulton .form-control {
    background-color: var(--surface-muted);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    color: var(--ink-800);
    font-family: var(--font-body);
    transition: all 0.2s ease;
}

.card-login-oulton .form-control:focus {
    background-color: var(--surface);
    border-color: var(--brand-400);
    box-shadow: 0 0 0 .2rem rgba(var(--brand-400-rgb), .18);
}

.card-login-oulton .btn-primary {
    background-color: var(--brand-500);
    border-color: var(--brand-500);
    color: #ffffff;
    padding: 0.75rem 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    transition: all 0.2s ease;
}

.card-login-oulton .btn-primary:hover {
    background-color: var(--brand-700);
    border-color: var(--brand-700);
    transform: translateY(-2px);
}

/* -------------------------------------------------------------------------
   3. LAYOUT TABLERO
   ------------------------------------------------------------------------- */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-ancho);
    min-width: var(--sidebar-ancho);
    background: var(--color-sidebar);
    color: #fff;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease, min-width 0.3s ease, width 0.3s ease;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}

.sidebar.collapsed {
    margin-left: calc(var(--sidebar-ancho) * -1);
}

.sidebar-logo {
    background-color: #ffffff;
    height: var(--topbar-alto); /* 60px: Obligamos a que tenga la misma altura que la topbar */
    display: flex;
    align-items: center; /* Centra el logo verticalmente */
    justify-content: center; /* Centra el logo horizontalmente */
    padding: 0 1rem; /* Quitamos el padding vertical, solo dejamos a los lados */
    
    /* Para que la línea coincida perfecto con la topbar, usamos el mismo borde */
    border-bottom: 1px solid var(--ink-100); 
}

.sidebar-logo img {
    width: 250px;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.sidebar-nav {
    padding: 1rem 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sidebar-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.sidebar-nav li {
    margin: 0.25rem 0.75rem;
}

.sidebar-nav li:last-child {
    margin-top: auto;
    margin-bottom: 1rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: var(--text-sm);
    transition: background 0.2s, color 0.2s;
}

.nav-item:hover {
    background: var(--color-sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--color-sidebar-activo);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.nav-item-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    height: 100%;
}

.nav-item-logo:hover .logo-img {
    transform: scale(1.03);
    opacity: 0.9;
}

.logo-img {
    max-height: 38px; /* Restringimos la altura para que respire dentro de los 60px */
    width: auto;      /* El ancho se ajusta proporcionalmente */
    display: block;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.nav-icon {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: center;
}

.layout-main {
    flex: 1;
    margin-left: var(--sidebar-ancho);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .layout-main {
    margin-left: 0;
}

.topbar {
    height: var(--topbar-alto);
    background: var(--surface);
    border-bottom: 1px solid var(--ink-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--shadow-sm);
}

.topbar-logo {
    display: none;
    width: 128px;
    height: auto;
    max-height: 38px;
    object-fit: contain;
}



.btn-toggle {
    background: none;
    border: 1px solid var(--ink-100);
    border-radius: var(--radius-sm);
    width: 40px;
    height: 40px;
    font-size: 1.15rem;
    cursor: pointer;
    color: var(--ink-800);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color .2s, color .2s;
}

.btn-toggle:hover {
    background: var(--brand-50);
    border-color: var(--brand-200);
    color: var(--brand-700);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-salir {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--danger-bg);
    color: var(--danger);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: var(--text-sm);
    transition: background 0.2s;
}

.btn-salir:hover {
    background: #f6d3d2;
    color: #a83e3b;
}

.contenido {
    flex: 1;
    padding: 1.5rem 2rem 2rem;
}

/* -------------------------------------------------------------------------
   4. CONTENIDO INTERNO
   ------------------------------------------------------------------------- */
.seccion-titulo {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--ink-900);
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

.info-paciente {
    background: var(--surface);
    border-left: 4px solid var(--brand-500);
    padding: 1rem 1.25rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    color: var(--ink-500);
    font-size: var(--text-sm);
}

.info-paciente strong {
    color: var(--ink-900);
    font-size: 1.05rem;
    font-weight: 700;
    font-family: var(--font-display);
}

.contenido .form-control {
    border-radius: var(--radius-sm);
    border-color: var(--ink-100);
    padding: 0.6rem 0.9rem;
    font-family: var(--font-body);
}

.contenido .form-control:focus {
    border-color: var(--brand-400);
    box-shadow: 0 0 0 .2rem rgba(var(--brand-400-rgb), .18);
}

/* --- Botones genéricos, alineados al sistema de Turnos --- */
.btn {
    font-family: var(--font-body);
    font-weight: 600;
    border-radius: var(--radius-sm);
    letter-spacing: 0.01em;
    font-size: var(--text-sm);
}

.btn-primary {
    --bs-btn-bg: var(--brand-500);
    --bs-btn-border-color: var(--brand-500);
    --bs-btn-hover-bg: var(--brand-700);
    --bs-btn-hover-border-color: var(--brand-700);
    --bs-btn-active-bg: var(--brand-800);
    --bs-btn-active-border-color: var(--brand-800);
    --bs-btn-disabled-bg: var(--brand-200);
    --bs-btn-disabled-border-color: var(--brand-200);
    --bs-btn-focus-shadow-rgb: 31, 130, 171;
}

.btn-outline-primary {
    --bs-btn-color: var(--brand-600);
    --bs-btn-border-color: var(--brand-500);
    --bs-btn-hover-bg: var(--brand-500);
    --bs-btn-hover-border-color: var(--brand-500);
    --bs-btn-active-bg: var(--brand-600);
    --bs-btn-active-border-color: var(--brand-600);
    --bs-btn-focus-shadow-rgb: 31, 130, 171;
}

.btn-secondary {
    --bs-btn-bg: var(--ink-500);
    --bs-btn-border-color: var(--ink-500);
    --bs-btn-hover-bg: var(--ink-700);
    --bs-btn-hover-border-color: var(--ink-700);
}

/* --- Cards y tablas modernizadas --- */
.contenido .card {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.contenido .table {
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 0;
    border: none;
    font-family: var(--font-body);
}

.contenido .table thead th {
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-500);
    background-color: var(--surface-muted);
    border-bottom: 2px solid var(--ink-100);
    border-right: none;
    padding: 1.2rem 1rem;
}

.contenido .table tbody td {
    vertical-align: middle;
    padding: 1.2rem 1rem;
    border-right: none;
    border-bottom: 1px solid var(--ink-100);
    color: var(--ink-800);
    font-size: 0.95rem;
}

.contenido .table tbody tr:hover td {
    background-color: var(--brand-50);
    transition: background-color 0.2s ease;
}

.badge,
.contenido .table .badge {
    font-weight: 600;
    padding: 0.5em 0.85em;
    border-radius: var(--radius-sm);
    border: none;
    letter-spacing: 0.3px;
    font-size: var(--text-xs);
}

.badge.bg-success { background-color: var(--success) !important; }
.badge.bg-secondary { background-color: var(--ink-500) !important; }
.badge.bg-primary { background-color: var(--brand-500) !important; }

/* Alineación centrada para las columnas de Estado, Informe e Imágenes */
.contenido .table th:nth-child(4),
.contenido .table th:nth-child(5),
.contenido .table th:nth-child(6),
.contenido .table td:nth-child(4),
.contenido .table td:nth-child(5),
.contenido .table td:nth-child(6) {
    text-align: center;
}

/* Botón Soporte en Sidebar */
.btn-soporte {
    background-color: var(--warning);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: var(--text-sm);
    transition: all 0.2s ease;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-soporte:hover {
    background-color: #a96c15;
    color: #ffffff;
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

/* -------------------------------------------------------------------------
   5. TOPBAR — AVATAR
   ------------------------------------------------------------------------- */
.avatar-container {
    position: relative;
    width: 42px;
    height: 42px;
    background-color: var(--ink-100);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.avatar-icon {
    color: var(--ink-300);
    font-size: 1.5rem;
    margin-top: 8px;
}

.status-dot {
    position: absolute;
    bottom: 0px;
    right: -2px;
    width: 14px;
    height: 14px;
    background-color: var(--success);
    border: 2px solid var(--surface);
    border-radius: 50%;
    z-index: 10;
}

/* -------------------------------------------------------------------------
   6. MODAL REPORTE DE PROBLEMAS (LOGIN)
   ------------------------------------------------------------------------- */
#modalProblema .modal-content,
#modalSoporte .modal-content {
    border: none;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-family: var(--font-body);
}

#modalProblema .modal-header,
#modalSoporte .modal-header {
    border-bottom: none;
    padding: 1.5rem 1.5rem 0.5rem;
}

#modalProblema .modal-title,
#modalSoporte .modal-title {
    font-family: var(--font-display);
    color: var(--brand-700);
    font-weight: 700;
    font-size: var(--text-xl);
}

#modalProblema .modal-body,
#modalSoporte .modal-body {
    padding: 1rem 1.5rem;
}

#modalProblema .form-label,
#modalSoporte .form-label {
    font-weight: 600;
    color: var(--ink-800);
    font-size: var(--text-sm);
}

#modalProblema .form-control,
#modalSoporte .form-control {
    background-color: var(--surface-muted);
    border: 1px solid var(--ink-200);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    color: var(--ink-800);
    font-family: var(--font-body);
    transition: all 0.2s ease;
}

#modalProblema .form-control:focus,
#modalSoporte .form-control:focus {
    background-color: var(--surface);
    border-color: var(--brand-400);
    box-shadow: 0 0 0 .2rem rgba(var(--brand-400-rgb), .18);
}

#modalProblema .modal-footer,
#modalSoporte .modal-footer {
    border-top: none;
    padding: 0.5rem 1.5rem 1.5rem;
    gap: 0.5rem;
}

#modalProblema .btn,
#modalSoporte .btn {
    border-radius: var(--radius-sm);
    padding: 0.6rem 1.2rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

#modalProblema .btn-secondary,
#modalSoporte .btn-secondary {
    background-color: var(--ink-100);
    color: var(--ink-700);
    border: none;
}

#modalProblema .btn-secondary:hover,
#modalSoporte .btn-secondary:hover {
    background-color: var(--ink-200);
    color: var(--ink-900);
}

#modalProblema .btn-primary,
#modalSoporte .btn-primary {
    background-color: var(--brand-500);
    border: none;
    color: #ffffff;
    font-weight: 700;
}

#modalProblema .btn-primary:hover,
#modalSoporte .btn-primary:hover {
    background-color: var(--brand-700);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* -------------------------------------------------------------------------
    7. RESPONSIVE
   ------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .sidebar {
        margin-left: calc(var(--sidebar-ancho) * -1);
    }

    .sidebar.mobile-open {
        margin-left: 0;
    }

    .layout-main {
        margin-left: 0;
    }

    .contenido {
        padding: 1rem;
    }

    .seccion-titulo {
        font-size: 1.4rem;
    }

    .topbar {
        padding: 0 1rem;
    }

    .topbar-logo {
        display: block;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .contenido .table thead {
        display: none;
    }

    .contenido .table,
    .contenido .table tbody,
    .contenido .table tr,
    .contenido .table td {
        display: block;
        width: 100%;
    }

    .contenido .table tr {
        display: block;
        margin-bottom: 1rem;
        background: var(--surface);
        border: 1px solid var(--ink-200);
        border-radius: var(--radius-md);
        padding: 0.75rem 0;
        box-shadow: var(--shadow-sm);
    }

    .contenido .table td {
        text-align: right;
        padding: 0.6rem 1rem;
        border: none;
        border-bottom: 1px solid var(--ink-100);
        position: relative;
    }

    .contenido .table td:last-child {
        border-bottom: none;
    }

    .contenido .table td::before {
        content: attr(data-titulo);
        float: left;
        font-weight: 700;
        color: var(--ink-500);
        text-transform: uppercase;
        font-size: 0.72rem;
        letter-spacing: 0.03em;
    }

    .contenido .table td.text-center {
        text-align: right;
    }

    .contenido .table td.td-vacio {
        text-align: center !important;
        padding: 2rem 1rem;
    }
    .contenido .table td.td-vacio::before {
        display: none; /* Oculta el pseudo-elemento si lo hubiera */
    }
}

@media (max-width: 480px) {
    .topbar-logo {
        width: 104px;
    }

    .usuario-info small {
        display: none;
    }

    .btn-salir span {
        display: none;
    }
}

/* Overlay para cerrar el sidebar tocando afuera, solo en mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(var(--brand-900-rgb), .5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* -------------------------------------------------------------------------
    8. FOOTER (login) — mismo patrón que "Turnos Online"
   ------------------------------------------------------------------------- */
.app-footer {
    background: var(--brand-900);
    color: #cfe3ea;
    padding: 1.75rem 0;
    margin-top: auto;
}

.app-footer__inner {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    align-items: center;
    text-align: center;
}

@media (min-width: 768px) {
    .app-footer__inner {
        flex-direction: row;
        justify-content: space-between;
        text-align: left;
    }
}

.app-footer__brand {
    font-family: var(--font-display);
    font-weight: 800;
    color: #fff;
    font-size: var(--text-sm);
}

.app-footer__meta {
    font-size: var(--text-xs);
    color: #9fc0cc;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: .3rem 1rem;
}

.app-footer__meta i { color: var(--brand-300); margin-right: .35rem; }

/* Íconos de archivos en la tabla */
.fa-file, .fa-image {
    font-size: 1.2rem;
    transition: all 0.2s ease;
    cursor: default;
}

.fa-file {
    color: var(--brand-500);
}

.fa-image {
    color: var(--ink-500);
}

.fa-file:hover {
    color: var(--brand-700);
    transform: scale(1.1);
}

.fa-image:hover {
    color: var(--ink-700);
    transform: scale(1.1);
}
