/* static/css/project.css */

/* =========================================
   1. VARIABLES & CONFIGURACIÓN
   ========================================= */
:root {
  /* --- PALETA DE COLORES TOLIFE --- */
  --tl-primary: #0083a4; /* Azul Oscuro (Principal) */
  --tl-secondary: #04b9e7; /* Azul Claro (Hover/Surnames) */
  --tl-grey: #676e70; /* Gris Texto */
  --tl-bg-body: #f8fbfd; /* Fondo suave */
  --tl-nav-hover: #e0f3ff; /* Fondo Nav Hover */

  /* --- SEMÁFORO (Traffic Lights) --- */
  --tl-status-green: #28a745;
  --tl-status-yellow: #ffc107;
  --tl-status-red: #dc3545;

  /* --- DIMENSIONES DEL LAYOUT --- */
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 80px;
  --header-height: 70px;

  /* --- MAPEO ESTRUCTURAL (Puente con base.html) --- */
  --primary-color: var(--tl-primary);
  --bs-primary: var(--tl-primary); /* Override de Bootstrap */
}

/* =========================================
   2. RESET GLOBAL & TIPOGRAFÍA
   ========================================= */
body {
  background-color: var(--tl-bg-body);
  font-family:
    'Raleway',
    system-ui,
    -apple-system,
    sans-serif;
  color: #333;
  overflow-x: hidden;
}

/* Fuentes específicas */
h1,
h2,
h3,
h4,
h5,
h6,
.text-tool-title,
.text-tool-table,
.text-surname,
.text-clinician,
.breadcrumb-title {
  font-family: 'Raleway', sans-serif;
}

.text-font-sofia,
.metric-card {
  font-family:
    'Sofia', sans-serif !important; /* Asegúrate de importar Sofia en el HTML */
}

/* Utilidades de Texto/Color */
.bg-tl-grey {
  background-color: var(--tl-grey) !important;
}
.text-color-tl-grey {
  color: var(--tl-grey) !important;
}

/* Títulos de sección estándar */
h2 {
  font-weight: 700;
  color: var(--tl-primary);
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 10px;
  border-bottom: 2px solid #e2e8f0;
}

/* =========================================
   3. LAYOUT PRINCIPAL (Sidebar & Wrapper)
   ========================================= */

/* --- Sidebar Base --- */
.sidebar {
  width: var(--sidebar-width);
  background-color: #ffffff;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1030;
  border-right: 1px solid #eee;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* --- Wrapper del Contenido --- */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

/* --- ESTADO COLAPSADO (Desktop) --- */
/* Cuando colapsa, se encoge a 80px (íconos) en vez de desaparecer */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .menu-text,
.sidebar.collapsed .nav-link span {
  display: none; /* Oculta textos */
}

.sidebar.collapsed .logo-img {
  max-height: 30px; /* Logo más pequeño */
}

.sidebar.collapsed .nav-link {
  justify-content: center; /* Centra íconos */
  padding-left: 0;
  padding-right: 0;
}

.sidebar.collapsed .nav-link i {
  margin-right: 0;
  font-size: 1.4rem;
}

/* Ajuste del contenido principal cuando el sidebar colapsa */
.main-wrapper.expanded {
  margin-left: var(--sidebar-collapsed-width);
}

/* --- NAVEGACIÓN SIDEBAR --- */
.sidebar .nav-link,
.sidebar a {
  display: flex;
  align-items: center;
  color: #333;
  padding: 12px 15px;
  border-radius: 8px;
  margin-bottom: 4px;
  text-decoration: none;
  font-size: 1rem; /* 16px solicitado */
  font-weight: 500;
  letter-spacing: 0.3px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.sidebar .nav-link i {
  font-size: 1.2rem;
  margin-right: 12px;
  color: var(--tl-grey);
  transition: color 0.2s;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background-color: var(--tl-nav-hover);
  color: var(--tl-primary);
  font-weight: 600;
}

.sidebar .nav-link:hover i,
.sidebar .nav-link.active i {
  color: var(--tl-primary);
}

/* Badges en Sidebar */
.nav-link .badge {
  margin-left: auto;
  font-size: 0.7rem;
}

.sidebar.collapsed .nav-link .badge {
  position: absolute;
  top: 5px;
  right: 5px;
}

/* Footer UE */
.eu-footer {
  border-top: 1px solid #e2e8f0;
  padding: 1rem;
  background-color: #fff;
}
.sidebar.collapsed .eu-footer {
  display: none; /* Ocultar footer complejo al colapsar */
}

/* =========================================
   4. HEADER
   ========================================= */
.header {
  height: var(--header-height);
  background-color: #fff;
  border-bottom: 1px solid #dee2e6;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.toggle-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--tl-grey);
  transition: color 0.2s ease;
  padding: 5px;
}

.toggle-btn:hover {
  color: var(--tl-primary);
}

/* Títulos Header */
.text-tool-title {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--tl-primary);
  letter-spacing: 0.5px;
}

/* User Dropdown Text */
.text-surname {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--tl-secondary);
}
.text-clinician {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--tl-primary);
  text-transform: uppercase;
}
/* =========================================
   5. COMPONENTES DEL DASHBOARD (ACTUALIZADO)
   ========================================= */

/* --- Contenedor de Tabla (Estilo Tarjeta) --- */
.table-card {
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  padding: 1.5rem;
  margin-top: 1.5rem;
  border: 1px solid #e2e8f0;
}

/* --- Forzar estilos en la Tabla (Django-Tables2) --- */
.table {
  margin-bottom: 0; /* Quitar margen extra de bootstrap */
  width: 100%;
}

/* Cabeceras de la tabla */
.table thead th {
  font-family: 'Raleway', sans-serif !important; /* FORZAR TU FUENTE */
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--tl-primary);
  background-color: #f8fbfd; /* Color de fondo muy suave */
  border-bottom: 2px solid var(--tl-secondary);
  border-top: none;
  padding: 12px 16px;
  vertical-align: middle;
}

/* Celdas del cuerpo */
.table tbody td {
  font-family: 'Raleway', sans-serif; /* O 'Inter' si prefieres legibilidad */
  font-size: 0.95rem;
  color: #475569;
  padding: 12px 16px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}

/* Hover en filas */
.table-hover tbody tr:hover {
  background-color: var(--tl-nav-hover);
  transition: background-color 0.2s ease;
}

/* Enlaces dentro de la tabla (ej: Nombres de pacientes) */
.table tbody td a {
  color: var(--tl-primary);
  font-weight: 600;
  text-decoration: none;
}
.table tbody td a:hover {
  color: var(--tl-secondary);
  text-decoration: underline;
}

/* --- Filtros (Crispy Forms) --- */
.filter-card {
  background-color: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid #e2e8f0;
}
/* =========================================
   6. HTMX & LOADERS
   ========================================= */
/* Barra superior de carga HTMX */
.htmx-indicator-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(to right, var(--tl-primary), var(--tl-secondary));
  z-index: 2000;
}

.htmx-request .htmx-indicator-bar,
.htmx-indicator-bar.htmx-request {
  display: block;
  animation: loading-slide 1.5s infinite linear;
  background-size: 200% 100%;
}

@keyframes loading-slide {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

/* =========================================
   7. RESPONSIVE (MÓVIL)
   ========================================= */
@media (max-width: 768px) {
  .sidebar {
    margin-left: calc(
      var(--sidebar-width) * -1
    ); /* Oculto completamente en móvil */
    width: var(--sidebar-width);
  }

  .sidebar.active {
    margin-left: 0;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
  }

  /* En móvil, el wrapper siempre ocupa el 100% */
  .main-wrapper,
  .main-wrapper.expanded {
    margin-left: 0;
  }

  /* Reset de estilos colapsados en móvil (siempre full si se abre) */
  .sidebar .logo-text,
  .sidebar .menu-text {
    display: block;
  }
  .sidebar .nav-link span {
    display: inline;
  }
}

/* =========================================
   8. METRIC CARDS (DETALLE PACIENTE)
   ========================================= */

/* Efecto de elevación al pasar el mouse */
.hover-lift {
  transition:
    transform 0.2s ease-in-out,
    box-shadow 0.2s ease-in-out;
}
.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1) !important;
}

/* Caja de valor destacado (El recuadro azul suave) */
.metric-value-box {
  background-color: var(--tl-nav-hover); /* Usa tu variable existente #e0f3ff */
  color: var(--tl-primary); /* Usa tu azul oscuro #0083a4 */
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  text-align: center;
  border: 1px solid rgba(0, 131, 164, 0.1); /* Borde sutil del color primario */
}

.metric-label {
  opacity: 0.85;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  font-family: 'Raleway', sans-serif;
  text-transform: uppercase;
  font-weight: 700;
}

/* Detalles pequeños (Min, Max, Std) */
.metric-detail-row {
  font-size: 0.85rem;
  color: var(--tl-grey);
}

.metric-detail-value {
  font-weight: 700;
  color: #333;
}

/* Contenedor de gráficos */
.chart-container-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

/* Clase para números grandes (No cursiva) */
.metric-number {
  font-family: 'Raleway', sans-serif !important;
  font-weight: 700 !important; /* Negrita fuerte */
  letter-spacing: -0.5px; /* Un poco más pegado para números se ve mejor */
  line-height: 1.2;
}
/* Utilidad para texto pequeño (menor que fs-6) */
.fs-7 {
  font-size: 0.8rem !important;
}

/* =========================================
   9. TARJETA DE PERFIL DE PACIENTE
   ========================================= */

/* --- Contenedor Principal --- */
.patient-card {
  background-color: #fff;
  transition: all 0.3s ease;
  border-left: 6px solid #dee2e6; /* Gris por defecto */
}

.patient-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08) !important;
}

/* --- Variantes de Riesgo (Borde Izquierdo) --- */
/* Mantenemos tus colores específicos de este componente */
.patient-card.text-low {
  border-left-color: #00c49f !important;
}
.patient-card.text-medium {
  border-left-color: #ffc107 !important;
}
.patient-card.text-high {
  border-left-color: #ff4c4c !important;
}

/* --- Badges de Estado (Píldoras) --- */
.status-badge-md {
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.4rem 1rem;
  border-radius: 50rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  display: inline-flex;
  align-items: center;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  color: #6c757d;
}

/* Colores de las Píldoras (Translucidos) */
.status-badge-md.text-low {
  background-color: rgba(0, 196, 159, 0.15);
  color: #008f72 !important;
  border-color: rgba(0, 196, 159, 0.2);
}

.status-badge-md.text-medium {
  background-color: rgba(255, 193, 7, 0.15);
  color: #d39e00 !important;
  border-color: rgba(255, 193, 7, 0.3);
}

.status-badge-md.text-high {
  background-color: rgba(255, 76, 76, 0.15);
  color: #cc0000 !important;
  border-color: rgba(255, 76, 76, 0.2);
}

/* --- Tipografía de Datos --- */
.info-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tl-grey);
  margin-bottom: 2px;
  font-weight: 600;
  font-family: 'Raleway', sans-serif;
}

.info-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #212529;
  font-family: 'Raleway', sans-serif; /* Consistencia de marca */
}

/* --- Caja de Icono --- */
.icon-box {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background-color: #f8f9fa;
  color: #495057;
  margin-right: 12px;
  font-size: 1.2rem;
  border: 1px solid #e9ecef;
  flex-shrink: 0; /* Evita que el icono se aplaste en pantallas muy pequeñas */
}
/* =========================================
   10. PÁGINAS DE AUTENTICACIÓN (LOGIN/SIGNUP)
   ========================================= */

/* Contenedor de la tarjeta de login */
.auth-card {
  background: #ffffff;
  border-radius: 12px;
  /* Sombra suave y elevada */
  box-shadow:
    0 10px 25px rgba(0, 0, 0, 0.05),
    0 5px 10px rgba(0, 0, 0, 0.01);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px; /* Ancho ideal para lectura */
  margin: 0 auto; /* Centrado horizontal */
  border-top: 5px solid var(--tl-primary); /* Toque de marca superior */
}

/* Títulos y Subtítulos */
.auth-title {
  color: var(--tl-primary);
  font-weight: 700;
  font-family: 'Raleway', sans-serif;
  margin-bottom: 0.5rem;
}

.auth-subtitle {
  color: var(--tl-grey);
  font-size: 0.95rem;
  margin-bottom: 2rem;
}

/* Iconos dentro de los labels */
.form-label i {
  color: var(--tl-secondary);
  margin-right: 5px;
}

/* Enlaces de ayuda (Forgot password, etc) */
.auth-link {
  color: var(--tl-primary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}
.auth-link:hover {
  color: var(--tl-secondary);
  text-decoration: underline;
}

/* Separador para "Sign Up" */
.auth-separator {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e9ecef;
  color: var(--tl-grey);
  font-size: 0.9rem;
  text-align: center;
}

/* --- FORZAR ESTILO DE INPUTS  */

.auth-card input[type='text'],
.auth-card input[type='email'],
.auth-card input[type='password'] {
  display: block;
  width: 100%;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: #212529;
  background-color: #fff;
  background-clip: padding-box;
  border: 1px solid #ced4da;
  border-radius: 6px;
  transition:
    border-color 0.15s ease-in-out,
    box-shadow 0.15s ease-in-out;
}

.auth-card input:focus {
  border-color: var(--tl-secondary);
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(4, 185, 231, 0.25); /* color secundario con opacidad */
}
/* Para el logo en todas las auth-cards */
.auth-logo {
  max-width: 160px;
  height: auto;
}

/* Para iconos muy grandes (ej. éxito o error) */
.fs-icon-xl {
  font-size: 3rem !important;
}

.fs-icon-xxl {
  font-size: 4rem !important;
}

/* Para textos de ayuda muy pequeños (si no tenías .fs-7 ya) */
.fs-7 {
  font-size: 0.8rem !important;
}
