/* Shell compartido por las páginas propias de Disau (agenda, reporting...):
   variables de color, reset y la barra lateral de navegación. Las páginas
   que lo usan añaden su propio <style> encima para lo específico de cada
   una.

   Esquema de color ("beige + azul marino", minimalista estilo Apple): el
   contenido (todo dentro de .disau-main) va en beige muy claro con texto
   casi negro cálido — nunca blanco/negro puros, para que se sienta más
   suave. La cabecera (.disau-topbar) y el menú lateral (.disau-sidebar) se
   quedan en azul marino oscuro a propósito (es el acento de marca), así
   que usan su propio juego de variables (--header-*) en vez de las
   generales de contenido (--body-*, --quiet, --border-color, --primary).

   Botones: --accent (verde) y --danger (rojo) son SIEMPRE pastel — fondo
   suave + texto en la versión oscura del mismo color, nunca texto blanco
   sobre pastel (no pasa contraste). --primary es el azul marino, con
   texto blanco encima porque ahí sí es lo bastante oscuro. */

:root {
  --primary: #141736;
  --primary-hover: #20284d;
  --primary-fg: #ffffff;

  --accent: #c9e6d0;
  --accent-hover: #b7dcc0;
  --accent-fg: #1f5c3a;
  --accent-border: #a9d4b4;

  --danger: #f3c8c2;
  --danger-hover: #eab8b0;
  --danger-fg: #8a2e22;
  --danger-border: #e2aba3;

  --warning: #f3ddb0;
  --warning-hover: #eccf95;
  --warning-fg: #8a5a12;
  --warning-border: #e4c489;

  /* Indicadores de estado (odontograma, badges, franjas de fila...): a
     diferencia de --accent/--danger de arriba, estos van SÓLIDOS (no
     pastel) porque llevan texto blanco encima o tienen que distinguirse
     de un vistazo en formas pequeñas (un diente, un badge de 10px) — el
     pastel se perdería. Reutilizan la misma familia de color que
     --accent/--danger/--warning pero en versión más saturada. */
  --status-red: #c1503f;
  --status-red-soft: rgba(193,80,63,0.12);
  --status-amber: #b5811f;
  --status-amber-soft: rgba(181,129,31,0.15);
  --status-green: #3f7a52;
  --status-green-soft: rgba(63,122,82,0.14);
  --status-grey: #8c8272;
  --status-grey-soft: rgba(140,130,114,0.15);

  --body-bg: #f6f2ea;
  --card-bg: #faf7f0;
  --panel-bg: #efe8d9;
  --border-color: #e2d9c8;
  --border-strong: #cdbfa6;
  --body-fg: #2c2a26;
  --quiet: #8c8272;

  --header-bg: #141736;
  --header-fg: #eef1f8;
  --header-border: #26304c;
  --header-quiet: #9aa3c0;
  --header-accent: #d9c9a3;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--body-bg);
  color: var(--body-fg);
  font-family: 'Inter', -apple-system, sans-serif;
}

.disau-shell { display: flex; min-height: 100vh; }

.disau-sidebar {
  width: 200px;
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--header-bg);
  color: var(--header-fg);
  border-right: 1px solid var(--header-border);
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

/* Bloque de usuario (bienvenida, cambiar contraseña, cerrar sesión) — ver
   partials/sidebar.html. Antes vivía en la barra superior de Django
   (#header/#user-tools), ahora la barra superior no existe y toda la
   navegación/acciones de usuario se concentran aquí. margin-top:auto lo
   ancla al fondo del sidebar cuando el menú no llena el alto disponible;
   si el menú es más largo que la pantalla, simplemente sigue después del
   último grupo y se llega a él haciendo scroll, como el resto del menú. */
.sidebar-usuario {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--header-border);
}
.sidebar-usuario-nombre {
  font-size: 11px;
  font-weight: 600;
  color: var(--header-fg);
  padding: 0 8px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-usuario-acciones {
  display: flex;
  flex-direction: column;
}
.sidebar-usuario-acciones a,
.sidebar-usuario-acciones button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 8px;
  border-radius: 4px;
  color: var(--header-quiet);
  text-decoration: none;
  font-size: 11px;
  font-family: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
.sidebar-usuario-acciones a:hover,
.sidebar-usuario-acciones button:hover {
  background: rgba(255,255,255,0.06);
  color: var(--header-fg);
}
#sidebar-logout-form { margin: 0; }
.disau-sidebar-logo {
  /* Fase 9 (pedido explícito): ~40px de margen entre el logo y el
     primer enlace (Inicio) — antes 16px de padding + 10px de margen
     (26px en total); ahora 16+24=40px. */
  display: block;
  padding: 2px 8px 16px;
  margin-bottom: 10px !important;
}
.disau-sidebar-logo:hover { background: none; }
.disau-sidebar-logo img { display: block; width: 100%; max-width: 150px; height: auto; }
.disau-sidebar .separador {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--header-quiet);
  margin: 16px 8px 6px;
}
.disau-sidebar a {
  display: block;
  padding: 7px 8px;
  border-radius: 4px;
  color: var(--header-fg);
  text-decoration: none;
  font-size: 12px;
  margin-bottom: 2px;
  border-left: 2px solid transparent;
}
.disau-sidebar a:hover { background: rgba(255,255,255,0.06); }
.disau-sidebar a.activo {
  color: var(--header-accent);
  background: rgba(217,201,163,0.16);
  border-left-color: var(--header-accent);
  font-weight: 600;
}

.disau-sidebar details.grupo-menu { margin: 0; }
.disau-sidebar details.grupo-menu + details.grupo-menu { margin-top: 4px; }
.disau-sidebar details.grupo-menu summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px;
  border-radius: 4px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--header-quiet);
  margin: 6px 0 2px;
}
.disau-sidebar details.grupo-menu summary::-webkit-details-marker { display: none; }
.disau-sidebar details.grupo-menu summary::after {
  content: '›';
  font-size: 12px;
  line-height: 1;
  transition: transform 0.15s ease;
}
.disau-sidebar details.grupo-menu[open] > summary::after { transform: rotate(90deg); }
.disau-sidebar details.grupo-menu summary:hover { color: var(--header-fg); }
.disau-sidebar details.grupo-menu a { margin-left: 6px; }

.disau-main { flex: 1; min-width: 0; }

.disau-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  background: var(--header-bg);
  color: var(--header-fg);
  border-bottom: 1px solid var(--header-border);
}
.disau-topbar h1 {
  /* Fase 9 (pedido explícito): fuera la tipografía secundaria (Space
     Grotesk) de los titulares — misma sans que el resto (Inter, ver
     "body" más abajo en este archivo), sin font-family propia aquí. */
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--header-fg);
}
/* Nombre y apellidos del paciente siempre en MAYÚSCULAS (solo al mostrarlo; el dato guardado no cambia). */
.nombre-paciente { text-transform: uppercase; }
.disau-topbar h1 .edad-paciente { font-weight: 500; opacity: .75; }
.disau-topbar a.volver {
  color: var(--header-quiet);
  text-decoration: none;
  font-size: 12px;
  border: 1px solid var(--header-border);
  border-radius: 4px;
  padding: 5px 10px;
}
.disau-topbar a.volver:hover { color: var(--header-fg); border-color: var(--header-accent); }

.disau-topbar .cabecera-con-flecha { display: flex; align-items: center; gap: 12px; min-width: 0; }
.disau-topbar a.flecha-volver {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid var(--header-border);
  color: var(--header-quiet);
  text-decoration: none;
  font-size: 14px;
  line-height: 1;
}
.disau-topbar a.flecha-volver:hover { color: var(--header-fg); border-color: var(--header-accent); }

/* Bolita de consentimiento junto al nombre de un tratamiento: verde = firmado,
   gris = pendiente de firma; sin bolita si el tratamiento no tiene consentimiento vinculado. */
.bolita-consent { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: baseline; position: relative; top: 0; flex: none; }
.bolita-consent.firmado { background: #3f7a52; }
.bolita-consent.pendiente { background: #b3b3b3; }

/* ===== Móvil / pantallas estrechas ======================================
   Solo se aplica por debajo de 900px: en ordenador no cambia nada. El menú
   lateral pasa a ser un panel que se abre con el botón ☰ (partials/sidebar.html),
   las tablas anchas se desplazan en horizontal dentro de su caja en vez de
   ensanchar la página, los modales ocupan la pantalla y los controles son
   más grandes para el dedo (16px en campos: iOS no hace zoom al enfocar). */
.disau-menu-btn, .disau-menu-fondo { display: none; }
@media (max-width: 900px) {
  html, body { height: auto; overflow-x: hidden; max-width: 100vw; }
  .disau-shell, #container .main { display: block; }
  #nav-sidebar { width: 0; padding: 0; }
  .disau-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100dvh; width: min(82vw, 290px);
    z-index: 1000; transform: translateX(-102%); transition: transform .2s ease;
    box-shadow: none; padding-top: 56px;
  }
  body.disau-menu-abierto .disau-sidebar { transform: none; box-shadow: 6px 0 24px rgba(0,0,0,.35); }
  body.disau-menu-abierto { overflow: hidden; }
  body.disau-menu-abierto .disau-menu-btn { z-index: 1001; }
  table select { min-width: 96px; }
  .disau-menu-btn {
    display: flex; align-items: center; justify-content: center;
    position: fixed; top: 8px; left: 8px; z-index: 45; width: 40px; height: 40px;
    border-radius: 8px; border: 1px solid var(--header-border); background: var(--header-bg);
    color: var(--header-fg); font-size: 20px; line-height: 1; cursor: pointer; padding: 0;
  }
  .disau-menu-fondo {
    position: fixed; inset: 0; z-index: 999; background: rgba(5,6,10,.5);
  }
  body.disau-menu-abierto .disau-menu-fondo { display: block; }
  .disau-sidebar a, .disau-sidebar button.enlace-lateral, .sidebar-usuario-acciones a,
  .sidebar-usuario-acciones button { padding: 11px 10px; font-size: 14px; }
  .disau-sidebar details.grupo-menu summary { padding: 11px 10px; font-size: 11px; }

  .disau-main, .main > .content { width: 100%; min-width: 0; }
  .disau-topbar {
    flex-wrap: wrap; gap: 8px; padding: 8px 12px 8px 58px; min-height: 56px;
  }
  .disau-topbar h1 { font-size: 14px; min-width: 0; overflow-wrap: break-word; flex: 0 1 auto; min-width: 6em; }
  .disau-topbar > * { max-width: 100%; }

  /* Contenido: sin márgenes laterales grandes. */
  .contenido { padding: 12px !important; }

  /* Tablas anchas: desplazamiento horizontal dentro de la propia tabla. */
  .disau-main table, .main > .content table {
    display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch;
  }
  img, video, canvas { max-width: 100%; }
  iframe { max-width: 100%; }

  /* Modales y cajas emergentes a casi pantalla completa. */
  [class*="modal-caja"], [class*="-caja"][class*="modal"], .sb-buscar-caja, [role="dialog"] {
    width: calc(100vw - 16px) !important; max-width: calc(100vw - 16px) !important;
    max-height: calc(100dvh - 16px) !important; overflow-y: auto;
  }
  [class*="modal-overlay"], [class*="modal-fondo"], .sb-buscar-overlay {
    padding: 8px !important; align-items: flex-start !important;
  }

  /* Controles táctiles. */
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px !important; }
  button, .btn, input[type=submit], input[type=button], a.button, .button { min-height: 38px; }
  input[type=checkbox], input[type=radio] { width: 20px; height: 20px; }

  /* Filas de formularios/rejillas de dos o más columnas: una columna. */
  .fila-2, .fila-3, .grid-2, .grid-3, .form-row, .columnas-2, .columnas-3 { grid-template-columns: 1fr !important; }
  #changelist.module { display: block; }
  #changelist-filter { width: 100% !important; max-width: 100%; margin: 12px 0 0 !important; position: static !important; flex: none; }
  .horario-wrap { padding: 12px !important; }
  .horario-mes { width: 100% !important; max-width: 100%; }
  input[type=file] { max-width: 100%; }
  .fila-controles, .fila-controles > * { min-width: 0; max-width: 100%; }
  #changelist .changelist-form-container { overflow-x: auto; }
}
@media (max-width: 480px) {
  .disau-topbar h1 { font-size: 13px; }
}

/* Etiqueta «1.ª vez»: la línea lleva el descuento de la condición especial de primera vez del grupo */
.etq-primera-vez { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 9.5px; font-weight: 700; letter-spacing: .2px; background: #ffe6cf; color: #7a4310; white-space: nowrap; vertical-align: middle; }
