/* ================================================================
   OMNISALUD - SISTEMA DE DISEÑO CORPORATIVO
   Basado en el Manual de Imagen Corporativa Oficial
   Colores: Azul #1C75BB | Magenta #E22084 | Azul Claro #009CE0
   Tipografía: Nunito (web equiv. Antipasto Pro) + Inter
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;500;600;700;800;900&family=Inter:wght@300;400;500;600;700&display=swap');

/* ----------------------------------------------------------------
   TOKENS DE COLOR — TEMA OSCURO (default)
   Basado en el fondo de presentaciones del manual:
   Degradado azul marino #0d1f3c → #1a3a6e
   ---------------------------------------------------------------- */
:root {
    /* Fondo */
    --bg-base:          #0d1a2e;
    --bg-surface:       rgba(18, 30, 54, 0.70);
    --bg-surface-solid: #121e36;
    --border-color:     rgba(28, 117, 187, 0.18);

    /* Texto */
    --text-primary:   #f0f4f9;
    --text-secondary: #9bb5cc;
    --text-muted:     #5d7d99;

    /* === COLORES CORPORATIVOS OMNISALUD === */
    /* Azul primario — HEX #1C75BB  (CMYK 100 40 0 0 / RGB 28 117 187) */
    --primary:          #1C75BB;
    --primary-dark:     #155a94;
    --primary-light:    #4494cc;
    --primary-glow:     rgba(28, 117, 187, 0.18);
    --primary-gradient: linear-gradient(135deg, #1C75BB 0%, #009CE0 100%);

    /* Magenta acento — HEX #E22084  (CMYK 0 100 0 0) */
    --accent:           #E22084;
    --accent-dark:      #b51a6a;
    --accent-light:     #ff4da0;
    --accent-glow:      rgba(226, 32, 132, 0.15);

    /* Azul cielo secundario — #009CE0 / #00BDEA */
    --secondary:        #009CE0;
    --secondary-light:  #00BDEA;

    /* Estados */
    --success:      #10b981;
    --success-glow: rgba(16, 185, 129, 0.15);
    --warning:      #f59e0b;
    --warning-glow: rgba(245, 158, 11, 0.15);
    --danger:       #ef4444;
    --danger-glow:  rgba(239, 68, 68, 0.15);

    /* Layout */
    --sidebar-width:           270px;
    --sidebar-collapsed-width: 80px;
    --header-height:           70px;

    /* Efectos */
    --glass-blur:  blur(18px);
    --shadow-main: 0 8px 40px 0 rgba(0, 0, 0, 0.45);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
    --radius-lg:   16px;
    --radius-md:   12px;
    --radius-sm:   8px;

    /* Tipografía */
    --font-heading: 'Nunito', sans-serif;
    --font-body:    'Inter', sans-serif;
}

/* ----------------------------------------------------------------
   TEMA CLARO — colores blancos institucionales del manual
   (logo sobre fondo blanco, páginas del manual)
   ---------------------------------------------------------------- */
body.light-mode {
    --bg-base:          #f0f4f8;
    --bg-surface:       rgba(255, 255, 255, 0.85);
    --bg-surface-solid: #ffffff;
    --border-color:     rgba(28, 117, 187, 0.14);

    --text-primary:   #0d1a2e;
    --text-secondary: #2d5a8a;
    --text-muted:     #6b8aa8;

    --primary-glow:  rgba(28, 117, 187, 0.10);
    --accent-glow:   rgba(226, 32, 132, 0.10);
    --shadow-main:   0 8px 32px 0 rgba(28, 117, 187, 0.10);
    --shadow-card:   0 4px 16px rgba(28, 117, 187, 0.08);
}

/* ================================================================
   BASE STYLES
   ================================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Fondo del body — en modo oscuro imitar presentación corporativa */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background:
        radial-gradient(ellipse at 15% 20%, rgba(28, 117, 187, 0.12) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 80%, rgba(0, 156, 224, 0.08) 0%, transparent 55%);
    pointer-events: none;
    z-index: 0;
}

body.light-mode::before {
    background:
        radial-gradient(ellipse at 10% 10%, rgba(28, 117, 187, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 90% 90%, rgba(0, 189, 234, 0.04) 0%, transparent 50%);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.01em;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ================================================================
   GLASS PANEL — componente base de tarjetas
   ================================================================ */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-main);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    position: relative;
    z-index: 1;
}

.glass-panel:hover {
    border-color: rgba(28, 117, 187, 0.35);
}

/* ================================================================
   LAYOUT PRINCIPAL
   ================================================================ */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
    background: var(--bg-surface-solid);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4,0,0.2,1);
    overflow: hidden;
}

/* Línea azul corporativa al borde izquierdo del sidebar */
.sidebar::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-gradient);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4,0,0.2,1);
    position: relative;
    padding: 30px;
    padding-top: calc(var(--header-height) + 30px);
    z-index: 1;
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* ================================================================
   SIDEBAR — LOGO OMNISALUD
   ================================================================ */
.sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
    overflow: hidden;
    flex-shrink: 0;
}

/* Ícono compacto: solo visible con el sidebar colapsado */
.sidebar-logo-icon {
    display: none;
    flex-shrink: 0;
    height: 32px;
    width: auto;
}

.sidebar.collapsed .sidebar-logo-icon {
    display: block;
}

/* Logo completo Omnisalud + nombre del sistema: visible con el sidebar expandido */
.sidebar-logo-full-group {
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-logo-full-group {
    display: none;
}

.sidebar-logo-full {
    height: 30px;
    width: auto;
    flex-shrink: 0;
}

/* Variante por tema: blanco sobre fondo oscuro (por defecto), color sobre fondo claro */
.sidebar-logo-full--light { display: none; }
body.light-mode .sidebar-logo-full--dark  { display: none; }
body.light-mode .sidebar-logo-full--light { display: block; }

/* Nombre del sistema, junto al logo de marca */
.sidebar-logo-suffix {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -0.01em;
    white-space: nowrap;
    padding-left: 10px;
    border-left: 1px solid var(--border-color);
    flex-shrink: 0;
}

/* ================================================================
   SIDEBAR — MENÚ
   ================================================================ */
.sidebar-menu {
    flex: 1;
    list-style: none;
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

.menu-section-title {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 14px 10px 4px 10px;
    letter-spacing: 0.08em;
}

.sidebar.collapsed .menu-section-title {
    display: none;
}

.menu-item a {
    display: flex;
    align-items: center;
    padding: 11px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    gap: 14px;
    font-weight: 500;
    font-size: 0.88rem;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
}

.menu-item a:hover {
    background: var(--primary-glow);
    color: var(--primary);
    transform: translateX(2px);
}

.menu-item.active a {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(28, 117, 187, 0.4);
    font-weight: 700;
}

.menu-item i {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

/* ================================================================
   SIDEBAR — FOOTER (usuario)
   ================================================================ */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.sidebar-footer .user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #ffffff;
    font-size: 1rem;
    flex-shrink: 0;
    font-family: var(--font-heading);
    border: 2px solid rgba(28, 117, 187, 0.3);
}

.sidebar-footer .user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-footer .user-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer .user-role {
    font-size: 0.72rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sidebar.collapsed .sidebar-footer .user-info {
    display: none;
}

/* ================================================================
   HEADER BAR
   ================================================================ */
.header-bar {
    height: var(--header-height);
    position: fixed;
    top: 0; right: 0;
    left: var(--sidebar-width);
    z-index: 99;
    background: var(--bg-surface);
    backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    transition: left 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* Franja azul corporativa en el borde inferior del header */
.header-bar::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: var(--primary-gradient);
}

.sidebar.collapsed ~ .header-bar {
    left: var(--sidebar-collapsed-width);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.breadcrumb .bc-sep { color: var(--text-muted); }
.breadcrumb .bc-current { color: var(--text-primary); font-weight: 600; }

.toggle-sidebar-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.toggle-sidebar-btn:hover {
    background: var(--primary-glow);
    color: var(--primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Logo Omnisalud pequeño en el header */
.header-logo-img {
    height: 18px;
    width: auto;
}

.header-logo-img--light { display: none; }
body.light-mode .header-logo-img--dark  { display: none; }
body.light-mode .header-logo-img--light { display: block; }

.theme-toggle-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.1rem;
    cursor: pointer;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.theme-toggle-btn:hover {
    background: var(--primary-glow);
    color: var(--primary);
}

/* ================================================================
   PÁGINAS Y CONTENIDO
   ================================================================ */
.page-header {
    margin-bottom: 30px;
}

.page-title {
    font-size: 2rem;
    color: var(--text-primary);
    font-weight: 800;
    font-family: var(--font-heading);
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.92rem;
    margin-top: 4px;
}

/* Decorador de título — línea azul izquierda */
.page-title-decorated {
    padding-left: 16px;
    border-left: 4px solid var(--primary);
}

/* ================================================================
   STATS GRID — Tarjetas KPI
   ================================================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    padding: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
}

/* Decorador diagonal inferior derecha (estilo del manual) */
.stat-card::after {
    content: '';
    position: absolute;
    bottom: -20px; right: -20px;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: var(--primary-glow);
    pointer-events: none;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 40px rgba(28, 117, 187, 0.25);
    border-color: var(--primary);
}

.stat-info { display: flex; flex-direction: column; }

.stat-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 900;
    font-family: var(--font-heading);
    margin-top: 4px;
    color: var(--text-primary);
    line-height: 1;
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.primary  { background: var(--primary-glow);  color: var(--primary); }
.stat-icon.accent   { background: var(--accent-glow);   color: var(--accent); }
.stat-icon.success  { background: var(--success-glow);  color: var(--success); }
.stat-icon.warning  { background: var(--warning-glow);  color: var(--warning); }
.stat-icon.danger   { background: var(--danger-glow);   color: var(--danger); }
.stat-icon.secondary { background: rgba(0,156,224,0.12); color: var(--secondary); }

/* ================================================================
   CHARTS GRID
   ================================================================ */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.chart-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.chart-title {
    font-size: 1.05rem;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 700;
    font-family: var(--font-heading);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-title::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 18px;
    background: var(--primary-gradient);
    border-radius: 2px;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 280px;
}

/* ================================================================
   BOTONES
   ================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    font-family: var(--font-heading);
    letter-spacing: 0.01em;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background 0.2s ease;
}

.btn:hover::after { background: rgba(255,255,255,0.08); }

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(28, 117, 187, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(28, 117, 187, 0.5);
}

.btn-accent {
    background: linear-gradient(135deg, #E22084 0%, #AF2680 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(226, 32, 132, 0.3);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(226, 32, 132, 0.45);
}

.btn-secondary {
    background: var(--primary-glow);
    color: var(--primary);
    border: 1px solid rgba(28, 117, 187, 0.25);
}

.btn-secondary:hover {
    background: rgba(28, 117, 187, 0.18);
    border-color: var(--primary);
}

.btn-ghost {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: rgba(255,255,255,0.10);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { filter: brightness(1.1); transform: translateY(-1px); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { filter: brightness(1.1); transform: translateY(-1px); }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-warning:hover  { filter: brightness(1.1); transform: translateY(-1px); }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius-lg); }

/* ================================================================
   FORMULARIOS E INPUTS
   ================================================================ */
.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-control {
    background: rgba(28, 117, 187, 0.06);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 11px 14px;
    font-size: 0.93rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    width: 100%;
}

.form-control::placeholder { color: var(--text-muted); }

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(28, 117, 187, 0.08);
    box-shadow: 0 0 0 3px rgba(28, 117, 187, 0.15);
}

body.light-mode .form-control {
    background: #f8fbff;
    border-color: rgba(28, 117, 187, 0.20);
}

body.light-mode .form-control:focus {
    background: #fff;
    border-color: var(--primary);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231C75BB' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 42px;
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ================================================================
   BADGES
   ================================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.73rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-family: var(--font-heading);
}

.badge-primary   { background: var(--primary-glow);  color: var(--primary); }
.badge-accent    { background: var(--accent-glow);   color: var(--accent); }
.badge-success   { background: var(--success-glow);  color: var(--success); }
.badge-warning   { background: var(--warning-glow);  color: var(--warning); }
.badge-danger    { background: var(--danger-glow);   color: var(--danger); }
.badge-info      { background: rgba(0,156,224,0.12); color: var(--secondary); }
.badge-secondary { background: rgba(0,156,224,0.12); color: var(--secondary); }
.badge-muted     { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* ================================================================
   FLASH MESSAGES
   ================================================================ */
.flash-container {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2;
    position: relative;
}

.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.35s cubic-bezier(0.4,0,0.2,1) forwards;
}

.alert-success { background: var(--success-glow);  border-left: 4px solid var(--success); color: var(--success); }
.alert-danger  { background: var(--danger-glow);   border-left: 4px solid var(--danger);  color: var(--danger); }
.alert-warning { background: var(--warning-glow);  border-left: 4px solid var(--warning); color: var(--warning); }
.alert-info    { background: var(--primary-glow);  border-left: 4px solid var(--primary); color: var(--primary); }

/* ================================================================
   CARD GRID — listas en tarjetas
   ================================================================ */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.data-card {
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

/* Franja de acento superior (estilo plantilla del manual) */
.data-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--primary-gradient);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.data-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 16px 40px rgba(28, 117, 187, 0.22);
    border-color: var(--primary);
}

.data-card-title {
    font-size: 1.15rem;
    margin-bottom: 6px;
    font-weight: 800;
    font-family: var(--font-heading);
    color: var(--text-primary);
}

.data-card-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.data-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.data-card-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.data-card-item i {
    width: 16px;
    color: var(--primary);
    flex-shrink: 0;
}

/* ================================================================
   DATA TABLE
   ================================================================ */
.data-table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

.data-table thead {
    background: var(--primary-gradient);
}

.data-table th {
    padding: 14px 18px;
    font-weight: 700;
    font-family: var(--font-heading);
    color: #ffffff;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border: none;
}

.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: background 0.15s ease;
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover td {
    background: var(--primary-glow);
}

body.light-mode .data-table tbody tr:hover td {
    background: rgba(28, 117, 187, 0.05);
}

/* ================================================================
   TABS
   ================================================================ */
.tabs-header {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 28px;
    overflow-x: auto;
}

.tab-btn {
    padding: 12px 20px;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: var(--font-heading);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn:hover {
    color: var(--primary);
    background: var(--primary-glow);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--primary-glow);
}

.tab-pane {
    display: none;
    animation: fadeIn 0.35s ease forwards;
}

.tab-pane.active { display: block; }

/* ================================================================
   MODALES
   ================================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(7, 15, 30, 0.7);
    backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 20px;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    width: 100%;
    max-width: 620px;
    padding: 32px;
    transform: translateY(20px) scale(0.96);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.modal-overlay.open .modal-box {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 800;
    font-family: var(--font-heading);
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.modal-close-btn:hover {
    background: var(--danger-glow);
    color: var(--danger);
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ================================================================
   PANEL CORPORATIVO — elemento visual del manual
   (esquinas con franjas diagonales azules)
   ================================================================ */
.corp-panel {
    position: relative;
    overflow: hidden;
}

.corp-panel::after {
    content: '';
    position: absolute;
    bottom: 0; right: 0;
    width: 120px;
    height: 60px;
    background: linear-gradient(135deg, transparent 40%, rgba(28,117,187,0.12) 40%, rgba(0,156,224,0.06) 70%, transparent 70%);
    pointer-events: none;
}

/* ================================================================
   BARRA DE PROGRESO
   ================================================================ */
.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(28, 117, 187, 0.12);
    border-radius: 20px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 20px;
    transition: width 0.6s ease;
}

.progress-fill.accent {
    background: linear-gradient(90deg, #E22084, #AF2680);
}

.progress-fill.success {
    background: linear-gradient(90deg, var(--success), #0d9668);
}

/* ================================================================
   SECTION DIVIDERS
   ================================================================ */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 800;
    font-family: var(--font-heading);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title i { color: var(--primary); }

/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    color: var(--border-color);
    margin-bottom: 16px;
    display: block;
}

.empty-state h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.88rem;
    max-width: 300px;
    margin: 0 auto 20px;
}

/* ================================================================
   SEARCH BOX
   ================================================================ */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box i {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.search-box .form-control {
    padding-left: 40px;
}

/* ================================================================
   STATUS INDICATOR — punto de estado
   ================================================================ */
.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 600;
}

.status-dot::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.active::before   { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.inactive::before { background: var(--text-muted); }
.status-dot.warning::before  { background: var(--warning); box-shadow: 0 0 6px var(--warning); }
.status-dot.danger::before   { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

/* ================================================================
   SEPARADOR VISUAL CON DIAGONAL (identidad manual Omnisalud)
   ================================================================ */
.omni-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
}

.omni-divider::before,
.omni-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-color), transparent);
}

.omni-divider-icon {
    width: 32px;
    height: 32px;
    background: var(--primary-gradient);
    border-radius: 6px;
    transform: rotate(45deg);
    flex-shrink: 0;
}

/* ================================================================
   ANIMACIONES
   ================================================================ */
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse-blue {
    0%, 100% { box-shadow: 0 0 0 0 rgba(28, 117, 187, 0.3); }
    50%       { box-shadow: 0 0 0 8px rgba(28, 117, 187, 0); }
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 992px) {
    .sidebar {
        width: var(--sidebar-collapsed-width);
    }
    .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }
    .header-bar {
        left: var(--sidebar-collapsed-width);
    }
    .sidebar-footer .user-info { display: none; }
    .sidebar-logo-full-group { display: none; }
    .sidebar-logo-icon { display: block; }
    .menu-section-title { display: none; }
    .menu-item a span { display: none; }
}

@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .main-content {
        padding: 16px;
        padding-top: calc(var(--header-height) + 16px);
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .card-grid {
        grid-template-columns: 1fr;
    }
}

/* ================================================================
   TABS — Sistema de pestañas para detalle de aliado
   ================================================================ */

/* Barra de botones de pestañas */
.tabs-header {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
    margin-bottom: 24px;
}

/* Botón individual de pestaña */
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--primary);
    background: var(--primary-glow);
}

/* Pestaña activa */
.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--primary-glow);
}

/* Panel de contenido — oculto por defecto */
.tab-pane {
    display: none;
    animation: fadeInTab 0.25s ease;
}

/* Panel activo — visible */
.tab-pane.active {
    display: block;
}

@keyframes fadeInTab {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsivo: scroll horizontal en tabs cuando hay muchas */
@media (max-width: 768px) {
    .tabs-header {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 0;
    }
    .tabs-header::-webkit-scrollbar {
        display: none;
    }
    .tab-btn {
        flex-shrink: 0;
        font-size: 0.78rem;
        padding: 8px 12px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   PWA — Progressive Web App UI Components
   Indicador offline, banners de instalación / actualización
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Indicador de estado offline ─────────────────────────────────────────── */
.pwa-offline-indicator {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #1e1e2e;
    border: 1px solid rgba(248, 113, 113, 0.4);
    border-radius: 100px;
    padding: 10px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fca5a5;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.pwa-offline-indicator i {
    font-size: 0.9rem;
    color: #f87171;
    animation: wifi-blink 1.8s ease-in-out infinite;
}

.pwa-offline-indicator.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

@keyframes wifi-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.35; }
}

.light-mode .pwa-offline-indicator {
    background: #fff5f5;
    border-color: rgba(239, 68, 68, 0.3);
    color: #b91c1c;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* ── Banner de Instalación ────────────────────────────────────────────────── */
.pwa-install-banner {
    position: fixed;
    bottom: -120px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9998;
    display: none;
    align-items: center;
    gap: 14px;
    background: var(--surface, #162232);
    border: 1px solid rgba(28, 117, 187, 0.3);
    border-radius: 16px;
    padding: 14px 20px;
    width: min(520px, calc(100vw - 32px));
    box-shadow: 0 -4px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(28,117,187,0.1);
    transition: bottom 0.4s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.3s ease;
    opacity: 0;
}

.pwa-install-banner.visible  { display: flex; bottom: 24px; }
.pwa-install-banner.animate-in { opacity: 1; }

.pwa-install-banner__icon { flex-shrink: 0; width: 44px; height: 36px; display: flex; align-items: center; }
.pwa-install-banner__icon svg { width: 44px; height: 36px; }

.pwa-install-banner__text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pwa-install-banner__text strong {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text, #f0f4f9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-install-banner__text span {
    font-size: 0.78rem;
    color: var(--text-muted, #6b8fad);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-install-banner__btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #1C75BB;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s, transform 0.15s;
    white-space: nowrap;
}

.pwa-install-banner__btn:hover { background: #1a6aad; transform: translateY(-1px); }

.pwa-install-banner__dismiss {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-muted, #6b8fad);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: color 0.2s, background 0.2s;
    font-family: inherit;
}

.pwa-install-banner__dismiss:hover { color: var(--text, #f0f4f9); background: rgba(255,255,255,0.08); }

.light-mode .pwa-install-banner { background: #ffffff; border-color: rgba(28,117,187,0.2); box-shadow: 0 8px 32px rgba(0,0,0,0.12); }
.light-mode .pwa-install-banner__text strong { color: #1a2840; }
.light-mode .pwa-install-banner__text span   { color: #5d7d99; }

@media (max-width: 540px) {
    .pwa-install-banner {
        border-radius: 16px 16px 0 0;
        left: 0;
        right: 0;
        bottom: -140px;
        transform: none;
        width: 100%;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }
    .pwa-install-banner.visible { bottom: 0; }
}

/* ── Banner de Actualización ──────────────────────────────────────────────── */
.pwa-update-banner {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9997;
    display: none;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #0d3a63, #1C75BB);
    border-radius: 100px;
    padding: 10px 20px;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(28,117,187,0.4);
    transition: top 0.4s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.3s ease;
    opacity: 0;
    white-space: nowrap;
}

.pwa-update-banner > i { font-size: 0.9rem; animation: spin-slow 3s linear infinite; }

@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.pwa-update-banner.visible   { display: flex; top: 16px; }
.pwa-update-banner.animate-in { opacity: 1; }

.pwa-update-banner__btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 100px;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 14px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
    white-space: nowrap;
}

.pwa-update-banner__btn:hover { background: rgba(255,255,255,0.32); }

.pwa-update-banner__dismiss {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 4px;
    font-family: inherit;
    transition: color 0.2s;
}

.pwa-update-banner__dismiss:hover { color: #fff; }

@media (max-width: 600px) {
    .pwa-update-banner {
        font-size: 0.78rem;
        padding: 9px 14px;
        gap: 8px;
        border-radius: 12px;
        white-space: normal;
        width: calc(100vw - 32px);
        top: -80px;
    }
    .pwa-update-banner.visible { top: 12px; }
}

/* ── Alerta offline para formularios ─────────────────────────────────────── */
.pwa-offline-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 12px;
    background: #1e1e2e;
    border: 1px solid rgba(248, 113, 113, 0.35);
    border-radius: 14px;
    padding: 16px 20px;
    max-width: 360px;
    width: 90%;
    color: #fca5a5;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    opacity: 0;
    transition: all 0.3s ease;
}

.pwa-offline-alert.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.pwa-offline-alert i    { font-size: 1.1rem; color: #f87171; flex-shrink: 0; }
.pwa-offline-alert span { flex: 1; }

.pwa-offline-alert button {
    background: transparent;
    border: none;
    color: rgba(252,165,165,0.6);
    cursor: pointer;
    padding: 2px;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: color 0.2s;
    font-family: inherit;
}

.pwa-offline-alert button:hover { color: #fca5a5; }

/* ── Ajustes para modo standalone ────────────────────────────────────────── */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* Ocultar banner de instalación si ya está instalada */
    .pwa-install-banner { display: none !important; }
}

/* ── Avisos flotantes (static/js/avisos.js) ─────────────────────────────── */
.avisos-contenedor {
    position: fixed; top: 16px; right: 16px; z-index: 10000;
    display: flex; flex-direction: column; gap: 10px;
    width: min(420px, calc(100vw - 32px));
}
.aviso {
    display: flex; gap: 12px; align-items: flex-start;
    background: var(--bg-surface-solid); color: var(--text-primary);
    border: 1px solid var(--border-color); border-left: 4px solid var(--primary);
    border-radius: 12px; padding: 14px 14px 14px 16px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    animation: aviso-entrar 0.2s ease-out;
}
.aviso-error       { border-left-color: var(--danger); }
.aviso-advertencia { border-left-color: var(--warning); }
.aviso-exito       { border-left-color: var(--success); }
.aviso-icono { font-size: 1.2rem; margin-top: 2px; color: var(--primary); }
.aviso-error .aviso-icono       { color: var(--danger); }
.aviso-advertencia .aviso-icono { color: var(--warning); }
.aviso-exito .aviso-icono       { color: var(--success); }
.aviso-cuerpo { flex: 1; min-width: 0; font-size: 0.86rem; line-height: 1.45; }
.aviso-titulo { display: block; font-size: 0.92rem; margin-bottom: 2px; }
.aviso-cuerpo p { margin: 0; color: var(--text-secondary); }
.aviso-cuerpo .aviso-accion { margin-top: 4px; color: var(--text-primary); }
.aviso-pie {
    display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center;
    margin-top: 8px; font-size: 0.74rem; color: var(--text-muted);
    font-family: ui-monospace, Consolas, monospace;
}
.aviso-copiar, .aviso-cerrar {
    background: none; border: 0; cursor: pointer; color: var(--text-muted); font: inherit;
}
.aviso-copiar { text-decoration: underline; padding: 0; font-family: 'Inter', sans-serif; }
.aviso-cerrar { font-size: 1rem; padding: 2px 4px; }
.aviso-cerrar:hover, .aviso-copiar:hover { color: var(--text-primary); }
@keyframes aviso-entrar { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
