/* 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 --- */
  --primary-color: var(--tl-primary);
  --bs-primary: var(--tl-primary);
}

/* =========================================
   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;
}

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;
}

/* Utilidades */
.bg-tl-grey {
  background-color: var(--tl-grey) !important;
}
.text-color-tl-grey {
  color: var(--tl-grey) !important;
}
.fs-7 {
  font-size: 0.8rem !important;
}

h2 {
  font-weight: 700;
  color: var(--tl-primary);
  font-size: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 10px;
  border-bottom: 2px solid #e2e8f0;
}

/* =========================================
   3. LAYOUT PRINCIPAL (Sidebar & Wrapper)
   ========================================= */
.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);
}

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

/* Sidebar Colapsado */
.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}
.sidebar.collapsed .logo-text,
.sidebar.collapsed .menu-text,
.sidebar.collapsed .nav-link span {
  display: none;
}
.sidebar.collapsed .logo-img {
  max-height: 30px;
}
.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 0;
}
.sidebar.collapsed .nav-link i {
  margin-right: 0;
  font-size: 1.4rem;
}
.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;
  font-weight: 500;
  letter-spacing: 0.3px;
  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);
}

.nav-link .badge {
  margin-left: auto;
  font-size: 0.7rem;
}
.sidebar.collapsed .nav-link .badge {
  position: absolute;
  top: 5px;
  right: 5px;
}

.eu-footer {
  border-top: 1px solid #e2e8f0;
  padding: 1rem;
  background-color: #fff;
}
.sidebar.collapsed .eu-footer {
  display: none;
}

/* =========================================
   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;
  padding: 5px;
}
.toggle-btn:hover {
  color: var(--tl-primary);
}
.text-tool-title {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--tl-primary);
  letter-spacing: 0.5px;
}
.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
   ========================================= */
.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;
}
.table {
  margin-bottom: 0;
  width: 100%;
}
.table thead th {
  font-family: 'Raleway', sans-serif !important;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.85rem;
  color: var(--tl-primary);
  background-color: #f8fbfd;
  border-bottom: 2px solid var(--tl-secondary);
  border-top: none;
  padding: 12px 16px;
  vertical-align: middle;
}
.table tbody td {
  font-family: 'Raleway', sans-serif;
  font-size: 0.95rem;
  color: #475569;
  padding: 12px 16px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}
.table-hover tbody tr:hover {
  background-color: var(--tl-nav-hover);
}
.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;
}
.filter-card {
  background-color: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border: 1px solid #e2e8f0;
}

/* =========================================
   6. HTMX & LOADERS (TODO UNIFICADO AQUÍ)
   ========================================= */

/* A) Barra Superior Global */
.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;
  }
}

/* B) Barra Local de Componente (Ej: Carga de gráficos) */
.loader-container {
  height: 4px;
  width: 100%;
  background-color: #e9ecef;
  overflow: hidden;
  border-radius: 4px;
  display: none;
  margin-bottom: 1rem;
}
.loader-container.htmx-request {
  display: block;
}

.indeterminate-bar {
  height: 100%;
  background-color: var(--tl-primary);
  width: 30%;
  border-radius: 4px;
  animation: sliding-bar 1.5s infinite ease-in-out;
}
@keyframes sliding-bar {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(400%);
  }
}

/* C) Efecto Fade In para contenido */
.fade-in-content {
  animation: fadeIn 0.3s ease-in;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =========================================
   7. RESPONSIVE
   ========================================= */
@media (max-width: 768px) {
  .sidebar {
    margin-left: calc(var(--sidebar-width) * -1);
    width: var(--sidebar-width);
  }
  .sidebar.active {
    margin-left: 0;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
  }
  .main-wrapper,
  .main-wrapper.expanded {
    margin-left: 0;
  }
  .sidebar .logo-text,
  .sidebar .menu-text {
    display: block;
  }
  .sidebar .nav-link span {
    display: inline;
  }
}

/* =========================================
   8. METRIC CARDS
   ========================================= */
.hover-lift {
  transition:
    transform 0.2s,
    box-shadow 0.2s;
}
.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1) !important;
}

.metric-value-box {
  background-color: var(--tl-nav-hover);
  color: var(--tl-primary);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  text-align: center;
  border: 1px solid rgba(0, 131, 164, 0.1);
}
.metric-label {
  opacity: 0.85;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  font-family: 'Raleway', sans-serif;
  text-transform: uppercase;
  font-weight: 700;
}
.metric-detail-row {
  font-size: 0.85rem;
  color: var(--tl-grey);
}
.metric-detail-value {
  font-weight: 700;
  color: #333;
}
.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);
}
.metric-number {
  font-family: 'Raleway', sans-serif !important;
  font-weight: 700 !important;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

/* =========================================
   9. TARJETA DE PERFIL DE PACIENTE
   ========================================= */
.patient-card {
  background-color: #fff;
  transition: all 0.3s;
  border-left: 6px solid #dee2e6;
}
.patient-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08) !important;
}
.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;
}
.status-badge-md {
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.4rem 1rem;
  border-radius: 50rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  border: 1px solid #dee2e6;
}
.status-badge-md.text-low {
  background: rgba(0, 196, 159, 0.15);
  color: #008f72 !important;
  border-color: rgba(0, 196, 159, 0.2);
}
.status-badge-md.text-medium {
  background: rgba(255, 193, 7, 0.15);
  color: #d39e00 !important;
  border-color: rgba(255, 193, 7, 0.3);
}
.status-badge-md.text-high {
  background: rgba(255, 76, 76, 0.15);
  color: #cc0000 !important;
  border-color: rgba(255, 76, 76, 0.2);
}
.info-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tl-grey);
  font-weight: 600;
  font-family: 'Raleway', sans-serif;
}
.info-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: #212529;
  font-family: 'Raleway', sans-serif;
}
.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;
}

/* =========================================
   10. PÁGINAS DE AUTENTICACIÓN
   ========================================= */
.auth-card {
  background: #ffffff;
  border-radius: 12px;
  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;
  margin: 0 auto;
  border-top: 5px solid var(--tl-primary);
}
.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;
}
.form-label i {
  color: var(--tl-secondary);
  margin-right: 5px;
}
.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;
}
.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;
}

.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;
  line-height: 1.5;
  color: #212529;
  background-color: #fff;
  border: 1px solid #ced4da;
  border-radius: 6px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.auth-card input:focus {
  border-color: var(--tl-secondary);
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(4, 185, 231, 0.25);
}

/* Utilidades Auth */
.auth-logo {
  max-width: 160px;
  height: auto;
}
.fs-icon-xl {
  font-size: 3rem !important;
}
.fs-icon-xxl {
  font-size: 4rem !important;
}

/* =========================================
   11. PERFIL DE USUARIO
   ========================================= */
.profile-card-container {
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
  border: 1px solid #e2e8f0;
  min-height: 60vh;
  position: relative;
  background-image: radial-gradient(circle at 10% 10%, #fcfdfd 0%, #f8fbfd 90%);
}
.profile-avatar-lg {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #fff;
  box-shadow: 0 8px 16px rgba(0, 131, 164, 0.15);
  margin-bottom: 1.5rem;
}
.profile-name {
  font-family: 'Raleway', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: #333;
  margin-bottom: 0.25rem;
}
.profile-role {
  font-family: 'Raleway', sans-serif;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--tl-primary);
  margin-bottom: 2rem;
}
.btn-logout-corner {
  background-color: var(--tl-secondary);
  color: white;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: 6px;
  padding: 0.5rem 1.5rem;
  border: none;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.btn-logout-corner:hover {
  background-color: var(--tl-primary);
  color: white;
  transform: translateY(-1px);
}

/* =========================================
   13. MENÚ VERTICAL COLAPSABLE (ACORDEÓN)
   ========================================= */

/* Sidebar Sticky Fix */
.sidebar-sticky-offset {
  position: -webkit-sticky;
  position: sticky;
  top: 90px;
  z-index: 900;
  /* Sin overflow ni max-height para evitar barra de scroll */
}

/* Botón de Categoría (Toggle) */
.category-toggle {
  width: 100%;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  margin-top: 5px;
  border-radius: 8px;
  color: #87919a;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-family: 'Raleway', sans-serif;
  transition: all 0.2s ease;
}
.category-toggle:hover {
  background-color: #f8f9fa;
  color: var(--bs-primary);
}
.category-toggle .chevron {
  transition: transform 0.3s ease;
  font-size: 0.8rem;
}
.category-toggle[aria-expanded='true'] .chevron {
  transform: rotate(180deg);
  color: var(--bs-primary);
}
.category-toggle[aria-expanded='true'] {
  color: var(--bs-primary);
}

/* Sub-items Container */
.collapse-inner {
  padding-left: 12px;
  margin-bottom: 10px;
  border-left: 2px solid #f1f5f9;
  margin-left: 15px;
}

/* Links (Estilo Original) */
.nav-pills-vertical .nav-link {
  border-radius: 6px;
  color: #495057;
  padding: 8px 15px;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s;
  border: 1px solid transparent;
  width: 100%;
  margin-bottom: 2px;
}
.nav-pills-vertical .nav-link:hover {
  background-color: #f8f9fa;
  color: var(--bs-primary);
  transform: translateX(3px);
}
.nav-pills-vertical .nav-link.active {
  background-color: var(--bs-primary);
  color: white;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

/* Botón Riesgo Principal */
.btn-risk-main {
  width: 100%;
  text-align: left;
  background-color: #fff5f5;
  color: #dc3545;
  font-weight: 700;
  padding: 12px 15px;
  border-radius: 8px;
  border: 1px solid rgba(220, 53, 69, 0.2);
  margin-bottom: 15px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}
.btn-risk-main:hover,
.btn-risk-main.active {
  background-color: #dc3545;
  color: white;
  box-shadow: 0 4px 10px rgba(220, 53, 69, 0.3);
  transform: translateY(-2px);
}

/* Utilidad de altura mínima para contenedores de carga */
.min-h-400 {
  min-height: 400px;
}

/* =========================================
   HTMX Loader & Animations
   ========================================= */

/* Contenedor de la barra de carga */
.loader-container {
  position: relative;
  height: 4px;
  width: 100%;
  /* Usa la variable de Bootstrap para el color primario con transparencia */
  background-color: rgba(var(--bs-primary-rgb), 0.1);
  overflow: hidden;
  border-radius: 4px 4px 0 0;
  opacity: 0; /* Oculto por defecto */
  transition: opacity 0.3s ease;
}

/* Clase automática que HTMX añade durante la petición */
.loader-container.htmx-request {
  opacity: 1;
}

/* La barra que se mueve */
.indeterminate-bar {
  position: absolute;
  width: 40%;
  height: 100%;
  background-color: var(--bs-primary); /* Color primario de Bootstrap */
  animation: sliding-bar 1.5s infinite ease-in-out;
  border-radius: 4px;
}

/* Animación de la barra */
@keyframes sliding-bar {
  0% {
    left: -40%;
  }
  50% {
    left: 20%;
    width: 80%;
  }
  100% {
    left: 100%;
    width: 10%;
  }
}

/* =========================================
   Content Transitions & Placeholders
   ========================================= */

/* Contenedor del contenido dinámico */
#measurement_content {
  transition: opacity 0.2s ease-in-out;
  min-height: 300px; /* Evita saltos bruscos del footer */
}

/* Efecto de parpadeo suave al cambiar contenido (HTMX) */
.htmx-settling #measurement_content {
  opacity: 0;
}

/* Estado vacío inicial */
.empty-state-placeholder {
  text-align: center;
  padding: 4rem 2rem;
  color: #6c757d;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.2;
}

/* Arreglar el widget de Bootstrap Datepicker Plus */
.input-group.date .form-control {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  font-size: 0.9rem;
}

.input-group.date .input-group-text {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  background-color: #f8f9fa; /* Fondo gris suave para el icono */
  border-color: #dee2e6;
  color: #6c757d;
}

/* Forzar que los inputs se vean planos y limpios */
.input-group-text,
.form-control {
  border-color: #e2e8f0 !important; /* Color borde sutil */
}

/* Hover suave en los inputs */
.form-control:focus {
  border-color: var(--bs-primary) !important;
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
}

/* --- ESTILOS PERFIL USUARIO (Tipo Card Central) --- */

/* Contenedor para centrar la tarjeta en el espacio disponible */
.profile-view-wrapper {
  min-height: 60vh; /* Altura mínima para centrar verticalmente */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
}

.profile-minimal-card {
  background: white;
  width: 100%;
  max-width: 650px;
  border-radius: 12px;
  /* Sombra suave como en la imagen */
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
  padding: 4rem 2rem;
  text-align: center;
  border: 1px solid #edf2f9;
}

/* Imagen circular (Avatar) */
.profile-avatar-img {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 1.5rem;
  background-color: #f8f9fa;
  /* Borde opcional si quieres que destaque más */
  border: 4px solid white;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

/* Tipografía */
.profile-name-text {
  font-size: 1.4rem;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 0.25rem;
}

.profile-role-text {
  font-size: 0.8rem;
  color: #00bcd4; /* Color Cyan de la imagen (Clinician) */
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 2.5rem;
}

/* Botón Cyan (Change Password) */
.btn-profile-action {
  background-color: #00bcd4; /* Mismo Cyan */
  color: white;
  border: none;
  padding: 0.7rem 2.5rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(0, 188, 212, 0.2);
}

.btn-profile-action:hover {
  background-color: #00acc1;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 6px 8px rgba(0, 188, 212, 0.3);
}

/* Selector de Idioma (Estilo minimalista) */
.language-selector-container {
  margin-top: 1.5rem;
  display: inline-block;
  position: relative;
}

.form-select-language {
  padding: 0.5rem 2.5rem 0.5rem 1rem;
  font-size: 0.9rem;
  color: #95a5a6;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  background-color: white;
  cursor: pointer;
  min-width: 200px;
  text-align: center;
  appearance: none; /* Quitamos flecha por defecto */
}

.form-select-language:hover {
  border-color: #ced4da;
}

.language-chevron {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #00bcd4;
  pointer-events: none;
  font-size: 0.8rem;
}
