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

:root {
  --bg-darkest: #090b11;      /* Fondo base del sistema */
  --bg-panel: #111520;        /* Barras laterales, navbar, tarjetas */
  --bg-viewport: #020306;     /* Fondo del visualizador de placas */
  --bg-control: rgba(255, 255, 255, 0.03);
  --bg-control-hover: rgba(255, 255, 255, 0.08);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-color-active: rgba(0, 200, 164, 0.4);
  --text-main: #f1f5f9;       /* Texto blanco-gris brillante */
  --text-muted: #94a3b8;      /* Texto descriptivo gris */
  --accent: #00c8a4;          /* Verde esmeralda corporativo */
  --accent-hover: #00b090;
  --accent-glow: rgba(0, 200, 164, 0.18);
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 4px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ==========================================
   AVISO DE SIN CONEXIÓN
   ========================================== */
/* En el flujo, no fixed: el body es flex column, así el aviso empuja la navbar
   hacia abajo en vez de taparla. */
.offline-banner {
  flex-shrink: 0;
  /* Por encima de la pantalla de login: si no hay red, también hay que avisarlo
     antes de que el usuario intente entrar y falle sin explicación. */
  position: relative;
  z-index: 10001;
  background: var(--warning);
  color: #1a1200;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  padding: 0.4rem 1rem;
  /* Respeta la zona segura del notch cuando corre instalada en iPhone */
  padding-top: max(0.4rem, env(safe-area-inset-top));
}

/* ==========================================
   PANTALLA DE LOGIN
   ========================================== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(circle at 50% 0%, #131a2b 0%, #090b11 60%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.login-card .form-group {
  margin-bottom: 0.9rem;
}

.login-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-bottom: 1.5rem;
}

.login-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  font-size: 0.76rem;
  line-height: 1.4;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-top: 0.75rem;
}

.login-foot {
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin-top: 1rem;
  text-align: center;
}

.login-foot code {
  background: var(--bg-control);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.65rem;
}

.empty-row td {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.7;
}

.empty-row td strong {
  color: var(--text-main);
  font-weight: 600;
}

.nav-user {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* La app queda oculta hasta que hay sesión, para no mostrar datos de pacientes
   ni por un instante mientras se valida el token. */
body.authenticating .navbar,
body.authenticating .dashboard-view,
body.authenticating .workspace,
body.authenticating .statusbar {
  visibility: hidden;
}

body, html {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-darkest);
  color: var(--text-main);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  touch-action: pan-x pan-y; /* Permite desplazamientos pero bloquea zoom nativo de página */
}

/* ==========================================
   NAVBAR (Estilo Corporativo)
   ========================================== */
.navbar {
  height: 60px;
  background-color: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 100;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
}

.brand-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--accent) 0%, #00a887 100%);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: var(--bg-darkest);
}

.brand-text {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.brand-text span {
  color: var(--accent);
}

/* Pestañas de Navegación */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 3rem;
  flex: 1;
}

.tab-item {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.tab-item:hover {
  color: #ffffff;
  background-color: var(--bg-control);
}

.tab-item.active {
  color: var(--accent);
  background-color: rgba(0, 200, 164, 0.08);
}

.badge-tool {
  background: rgba(0, 200, 164, 0.08);
  color: var(--accent);
  border: 1px solid rgba(0, 200, 164, 0.25);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  font-weight: 600;
}

/* ==========================================
   VISTA 1: DASHBOARD DE PACIENTES
   ========================================== */
.dashboard-view {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dashboard-title h2 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.dashboard-title p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

/* Filtros y Búsqueda */
.dashboard-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: var(--radius-lg);
}

.search-box {
  position: relative;
  width: 320px;
}

.search-box input {
  padding-left: 2.25rem !important;
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.9rem;
}

.filter-tags {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  background-color: var(--bg-control);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
}

.filter-tag:hover {
  border-color: rgba(255,255,255,0.2);
  color: #fff;
}

.filter-tag.active {
  background-color: var(--accent);
  color: var(--bg-darkest);
  border-color: var(--accent);
}

/* Grilla de Datos */
.patients-table-container {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.4);
}

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

.patients-table th {
  background-color: rgba(0,0,0,0.15);
  color: var(--text-muted);
  font-weight: 600;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.patients-table td {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

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

.patients-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.015);
}

/* Badges de Estado */
.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  display: inline-block;
  letter-spacing: 0.02em;
}

.status-badge.completado {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.borrador {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-badge.pendiente {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ==========================================
   VISTA 2: VISOR PACS CLÍNICO
   ========================================== */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Sidebar Izquierdo */
.sidebar {
  width: 280px;
  background-color: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.drag-drop-container {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.drag-drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.005);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.drag-drop-zone:hover {
  border-color: var(--accent);
  background-color: rgba(0, 200, 164, 0.03);
}

.drag-drop-icon {
  font-size: 1.5rem;
  color: var(--accent);
}

.drag-drop-zone h3 {
  font-size: 0.8rem;
  font-weight: 600;
}

.drag-drop-zone p {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.file-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.file-item {
  background-color: var(--bg-control);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 0.5rem;
}

.file-item.active {
  background-color: rgba(0, 200, 164, 0.04);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.file-thumbnail {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background-color: #000;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.file-name {
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Chat Médico Colaborativo */
.chat-container {
  height: 250px;
  display: flex;
  flex-direction: column;
  background-color: rgba(0,0,0,0.1);
  overflow: hidden;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-bubble {
  background-color: var(--bg-control);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.65rem;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.65rem;
  margin-bottom: 0.25rem;
}

.chat-doc {
  color: var(--accent);
  font-weight: 600;
}

.chat-time {
  color: var(--text-muted);
}

.chat-body {
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--text-main);
}

.chat-input-row {
  display: flex;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-panel);
}

.chat-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  padding: 0.6rem 0.75rem;
  font-size: 0.75rem;
  outline: none;
}

/* Visualizador Central */
.viewer-area {
  flex: 1;
  background-color: var(--bg-viewport);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

#viewer-canvas {
  flex: 1;
  display: block;
  touch-action: none; /* Control absoluto de gestos táctiles en JS */
}

/* Panel Lateral Derecho */
.adjustments-panel {
  width: 280px;
  background-color: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 1.25rem;
  gap: 1.25rem;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4rem;
}

/* Sliders */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}

.slider-label-row input[type="number"] {
  width: 50px;
  background-color: var(--bg-darkest);
  border: 1px solid var(--border-color);
  color: var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.2rem;
  font-size: 0.7rem;
  text-align: center;
  outline: none;
  font-weight: 600;
}

/* Presets de Ventana */
.presets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.btn-preset {
  background-color: var(--bg-control);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.btn-preset:hover {
  background-color: var(--bg-control-hover);
  color: #fff;
}

.btn-preset.active {
  background-color: rgba(0, 200, 164, 0.08);
  border-color: var(--accent);
  color: var(--accent);
}

/* Calibración */
.calibration-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background-color: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  padding: 0.6rem;
  border-radius: var(--radius-md);
}

.calibration-group label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.calibration-input-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.calibration-input-row input {
  flex: 1;
  background-color: var(--bg-darkest);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  outline: none;
}

.calibration-unit {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
}

/* Editor de Informe Radiológico */
.report-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.report-editor textarea {
  height: 120px;
  background-color: var(--bg-darkest);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-md);
  padding: 0.5rem;
  font-family: inherit;
  font-size: 0.75rem;
  line-height: 1.4;
  resize: none;
  outline: none;
}

.report-editor textarea:focus {
  border-color: var(--border-color-active);
}

/* AI Copilot Box */
.ai-copilot-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Aviso de qué sale del servidor. Va en ámbar y no en gris como el resto de los
   descargos: el médico tiene que verlo, porque de esto depende que no mande
   datos de un paciente a un tercero sin darse cuenta. */
.ai-privacy-warning {
  font-size: 0.66rem;
  line-height: 1.4;
  color: var(--warning);
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem;
  margin-top: 0.5rem;
}

.ai-disclaimer {
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

.ai-anmat-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fbbf24; /* Amber color */
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ai-box {
  background: rgba(10, 14, 24, 0.95);
  border: 1px solid rgba(0, 200, 164, 0.25);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1rem;
  max-height: 550px;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.ai-report-rendered {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 0.82rem;
  line-height: 1.55;
  color: #e2e8f0;
}

.ai-report-rendered h2, .ai-report-rendered h3 {
  color: #ffffff;
  background: rgba(0, 200, 164, 0.08);
  border-left: 3px solid var(--accent);
  padding: 0.4rem 0.75rem;
  margin-top: 1.25rem;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  letter-spacing: 0.5px;
}

.ai-report-rendered h2:first-of-type, .ai-report-rendered h3:first-of-type {
  margin-top: 0.25rem;
}

.ai-report-rendered p {
  margin-bottom: 0.75rem;
  text-align: justify;
}

.ai-report-rendered ul {
  margin-bottom: 0.85rem;
  padding-left: 1.1rem;
  list-style-type: square;
}

.ai-report-rendered li {
  margin-bottom: 0.35rem;
  color: #cbd5e1;
}

.ai-report-rendered li strong, .ai-report-rendered p strong {
  color: var(--accent);
  font-weight: 600;
}

.ai-report-rendered hr {
  border: 0;
  height: 1px;
  background: linear-gradient(to right, rgba(0, 200, 164, 0.4), transparent);
  margin: 1.1rem 0;
}

.ai-report-metadata {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 0.6rem;
  margin-bottom: 1.1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  font-size: 0.75rem;
}

.ai-report-metadata-item {
  color: #94a3b8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
  padding-bottom: 0.2rem;
}

.ai-report-metadata-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.ai-report-metadata-item strong {
  color: #f1f5f9;
}

/* ==========================================
   BARRA DE HERRAMIENTAS FLOTANTE
   ========================================== */
.toolbar-container {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(17, 21, 32, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  padding: 0.35rem;
  border-radius: 50px;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
  z-index: 10;
}

.btn-tool {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.btn-tool svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.btn-tool:hover {
  color: #ffffff;
  background-color: var(--bg-control-hover);
}

.btn-tool.active {
  color: var(--accent);
  background-color: rgba(0, 200, 164, 0.12);
  box-shadow: 0 0 10px var(--accent-glow) inset;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background-color: var(--border-color);
  margin: 0 0.2rem;
}

/* Tooltip nativo */
.btn-tool[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: -32px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--bg-panel);
  color: #ffffff;
  font-size: 0.65rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: var(--transition);
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

.btn-tool[data-tooltip]:hover::after {
  opacity: 1;
}

/* ==========================================
   MODALES (Popups)
   ========================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: var(--transition);
}

.modal-content {
  background-color: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 480px;
  padding: 1.5rem;
  box-shadow: 0 20px 40px -15px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
select {
  background-color: var(--bg-darkest);
  border: 1px solid var(--border-color);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 0.6rem 0.85rem;
  font-size: 0.8rem;
  outline: none;
  font-family: inherit;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus {
  border-color: var(--border-color-active);
}

/* ==========================================
   BOTONES
   ========================================== */
.btn {
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
}

.btn-primary {
  background-color: var(--accent);
  color: var(--bg-darkest);
  border: none;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  box-shadow: 0 0 15px var(--accent-glow);
}

.btn-secondary {
  background-color: var(--bg-control);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--bg-control-hover);
}

.btn-danger {
  background-color: var(--danger);
  color: #fff;
  border: none;
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-text:hover {
  color: #fff;
}

/* ==========================================
   BARRA DE ESTADO INFERIOR
   ========================================== */
.statusbar {
  height: 26px;
  background-color: var(--bg-panel);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.status-item strong {
  color: var(--text-main);
}

/* ==========================================
   TOASTS (Notificaciones emergentes)
   ========================================== */
.toast {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-panel);
  border: 1px solid var(--accent);
  color: #ffffff;
  padding: 0.55rem 1.25rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  z-index: 1000;
  transition: bottom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
  opacity: 0;
  pointer-events: none;
}

.toast.show {
  bottom: 2rem;
  opacity: 1;
}

.hidden {
  display: none !important;
}

#file-input {
  display: none;
}

.empty-chat {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
  margin-top: 2rem;
}

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

/* ==========================================
   RESPONSIVO PARA DISPOSITIVOS MÓVILES
   ========================================== */
.mobile-tabs-bar {
  display: none; /* Oculto en escritorio */
}

@media (max-width: 768px) {
  /* Navbar adaptativo */
  .navbar {
    padding: 0 0.5rem;
    height: 55px;
  }
  
  .brand {
    gap: 0.4rem;
  }
  
  .brand-icon {
    width: 26px;
    height: 26px;
    font-size: 0.85rem;
  }
  
  .brand-text {
    font-size: 0.95rem;
  }
  
  .nav-tabs {
    margin-left: 0.5rem;
    gap: 0.2rem;
  }
  
  .tab-item {
    font-size: 0.7rem;
    padding: 0.35rem 0.5rem;
    gap: 0.25rem;
  }
  
  /* Ocultar los links de soporte y versión en móvil */
  .nav-links {
    display: none !important;
  }
  
  /* Ocultar el texto largo de las pestañas en móvil, dejando sólo iconos */
  .tab-text {
    display: none !important;
  }

  /* Vista de Dashboard en móvil */
  .dashboard-view {
    padding: 1rem 0.75rem;
    gap: 1rem;
  }
  
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .dashboard-title h2 {
    font-size: 1.3rem;
  }
  
  .dashboard-actions {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
    gap: 0.75rem;
  }
  
  .search-box {
    width: 100%;
  }
  
  .filter-tags {
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  
  .filter-tag {
    padding: 0.3rem 0.65rem;
    font-size: 0.7rem;
  }
  
  .patients-table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
  }
  
  .patients-table th, .patients-table td {
    padding: 0.85rem 0.75rem;
  }

  /* Workspace (Visor) en móvil */
  .workspace {
    display: grid !important;
    grid-template-rows: 1fr 52px !important;
    height: calc(100dvh - 55px - 26px) !important;
    flex-direction: unset !important;
  }
  
  /* Barra de Navegación del Workspace (Mobile) */
  .mobile-tabs-bar {
    grid-row: 2 / 3 !important;
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: var(--bg-panel);
    border-top: 1px solid var(--border-color);
    height: 52px;
    width: 100%;
    z-index: 200;
    flex-shrink: 0;
  }
  
  .mobile-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.4rem;
    cursor: pointer;
    flex: 1;
    transition: var(--transition);
  }
  
  .mobile-tab-btn.active {
    color: var(--accent);
    background-color: rgba(0, 200, 164, 0.03);
  }
  
  .mobile-tab-icon {
    font-size: 1.1rem;
  }
  
  .mobile-tab-label {
    font-size: 0.6rem;
    font-weight: 600;
  }

  /* Paneles del Workspace en Móvil */
  .sidebar, .viewer-area, .adjustments-panel {
    grid-row: 1 / 2 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    border: none !important;
    flex: none !important;
  }
  
  /* Ocultar los paneles que no estén activos en móvil */
  .sidebar:not(.mobile-active),
  .adjustments-panel:not(.mobile-active),
  .viewer-area:not(.mobile-active) {
    display: none !important;
  }
  
  /* Barra de herramientas flotante en móvil */
  .toolbar-container {
    top: 0.5rem;
    padding: 0.2rem;
    gap: 0.1rem;
    max-width: 95%;
  }
  
  .btn-tool {
    width: 26px;
    height: 26px;
  }
  
  .btn-tool svg {
    width: 14px;
    height: 14px;
  }
  
  /* Ajustar tamaño del editor del informe */
  .report-editor textarea {
    height: 90px;
  }
  
  .ai-box {
    max-height: 280px;
    padding: 0.85rem;
  }
  
  .ai-report-rendered {
    font-size: 0.78rem;
  }
  
  /* Chat y listas */
  .chat-container {
    height: 180px;
  }
  
  .file-list-container {
    max-height: 150px;
  }
}

/* Banner flotante de herramienta activa (Mobile & Desktop) */
.active-tool-banner {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1.25rem;
  border-radius: 50px;
  font-size: 0.72rem;
  color: var(--text-main);
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 90%;
  text-align: center;
}

.active-tool-banner strong {
  color: var(--accent);
}

/* Historial de mediciones en panel lateral */
.measurements-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 150px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.measurement-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.72rem;
  transition: var(--transition);
}

.measurement-item:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

.measurement-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.measurement-type {
  font-weight: bold;
  color: var(--text-muted);
  font-size: 0.65rem;
  text-transform: uppercase;
}

.measurement-val {
  color: var(--text-main);
}

.btn-delete-measurement {
  background: transparent;
  border: none;
  color: #ef4444;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-delete-measurement:hover {
  background-color: rgba(239, 68, 68, 0.15);
}

.empty-measurements {
  color: var(--text-muted);
  font-size: 0.7rem;
  font-style: italic;
  text-align: center;
  padding: 0.5rem 0;
}

/* Botón de Dictado por Voz (Micrófono) */
.btn-voice-mic {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
  z-index: 10;
}

.btn-voice-mic:hover {
  background: rgba(0, 200, 164, 0.15);
  border-color: var(--accent);
}

.btn-voice-mic.recording {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  color: #fff !important;
  animation: pulse-mic 1.2s infinite;
}

@keyframes pulse-mic {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}
