/* ==========================================================================
   SISTEMA DE FICHERO MÉDICO - DRA. CASARES
   Estilos Corporativos y Diseño Responsivo / Mobile-First
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Paleta Corporativa Dra. Casares (Extraída de logocasares.png) */
  --primary: #0D3B4C;
  --primary-hover: #155169;
  --primary-light: #E7F1F4;
  --primary-dark: #072530;
  
  --secondary: #4E878C;
  --secondary-hover: #3C6E72;
  --secondary-light: #EBF4F4;
  
  --accent-gold: #C2B280;
  --accent-gold-hover: #AF9E6B;
  --accent-gold-light: #FAF7EF;
  --accent-gold-dark: #8C7B49;

  /* Colores de Interfaz - Modo Claro */
  --bg-main: #F3F7F6;
  --bg-card: #FFFFFF;
  --bg-card-glass: rgba(255, 255, 255, 0.85);
  --bg-subtle: #F8FBFA;
  --bg-input: #FFFFFF;
  
  --text-main: #132830;
  --text-muted: #5D7983;
  --text-light: #8CA3AB;
  --text-inverse: #FFFFFF;
  
  --border-color: #DEEAE8;
  --border-focus: #4E878C;

  /* Estados Clínicos */
  --badge-normal-bg: #E6F6ED;
  --badge-normal-text: #177C47;
  --badge-warning-bg: #FEF3C7;
  --badge-warning-text: #B45309;
  --badge-danger-bg: #FEE2E2;
  --badge-danger-text: #B91C1C;
  --badge-info-bg: #E0F2FE;
  --badge-info-text: #0369A1;

  /* Sombras y Radios */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 8px rgba(13, 59, 76, 0.05);
  --shadow-md: 0 8px 24px rgba(13, 59, 76, 0.08);
  --shadow-lg: 0 16px 40px rgba(13, 59, 76, 0.12);
  --shadow-float: 0 12px 30px rgba(13, 59, 76, 0.25);

  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --header-height: 72px;
  --bottom-nav-height: 68px;
}

[data-theme="dark"] {
  --bg-main: #09171C;
  --bg-card: #10262F;
  --bg-card-glass: rgba(16, 38, 47, 0.85);
  --bg-subtle: #15323D;
  --bg-input: #0D2028;
  
  --text-main: #F1F7F9;
  --text-muted: #9BB3BC;
  --text-light: #6E8891;
  --text-inverse: #09171C;
  
  --border-color: #1A3E4D;
  --border-focus: #4E878C;

  --primary-light: #163642;
  --secondary-light: #16373A;
  --accent-gold-light: #2A2617;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --shadow-float: 0 12px 30px rgba(0, 0, 0, 0.6);
}

/* Base & Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  transition: background-color 0.3s ease, color 0.3s ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 24px;
}

@media (max-width: 768px) {
  body {
    padding-bottom: calc(var(--bottom-nav-height) + 24px);
  }
}

/* Scrollbar estilizada */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: var(--secondary);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ==========================================================================
   HEADER PRINCIPAL
   ========================================================================== */
.main-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--bg-card-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: var(--text-main);
}

.brand-logo-img {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 2px solid var(--accent-gold);
  box-shadow: 0 3px 10px rgba(13, 59, 76, 0.18);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.brand-logo-img:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 14px rgba(13, 59, 76, 0.25);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.5px;
  line-height: 1.1;
}

[data-theme="dark"] .brand-title {
  color: #FFFFFF;
}

.brand-subtitle {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--secondary);
}

/* Header Controls & Desktop Nav */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.desktop-nav {
  display: flex;
  gap: 6px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.nav-tab-btn {
  background: transparent;
  border: none;
  padding: 8px 18px;
  font-family: var(--font-heading);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s ease;
}

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

.nav-tab-btn.active {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: 0 2px 10px rgba(13, 59, 76, 0.25);
}

[data-theme="dark"] .nav-tab-btn.active {
  background: var(--secondary);
  color: #FFFFFF;
}

/* Indicador de Estado de Conexión */
.connection-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.connection-badge:hover {
  border-color: var(--secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9CA3AF;
}

.status-dot.connected {
  background: #10B981;
  box-shadow: 0 0 8px #10B981;
}

.status-dot.local {
  background: var(--accent-gold);
}

.status-dot.syncing {
  background: #3B82F6;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { opacity: 0.3; }
  50% { opacity: 1; }
  100% { opacity: 0.3; }
}

/* Icon Buttons */
.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--secondary);
  transform: translateY(-1px);
}

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */
.app-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  flex: 1;
}

@media (max-width: 768px) {
  .app-container {
    padding: 16px 12px;
  }
}

/* Top Banner / Quick Actions Hero */
.hero-banner {
  background: linear-gradient(135deg, var(--primary) 0%, #154658 100%);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  color: #FFFFFF;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(194, 178, 128, 0.3);
}

.hero-banner::after {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(194, 178, 128, 0.2) 0%, transparent 70%);
  pointer-events: none;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.3px;
}

.hero-subtitle {
  font-size: 0.9rem;
  opacity: 0.85;
}

.hero-actions {
  display: flex;
  gap: 12px;
}

/* Botones Principales */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
  box-shadow: 0 4px 14px rgba(13, 59, 76, 0.25);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--secondary);
  color: #FFFFFF;
}

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

.btn-accent {
  background: var(--accent-gold);
  color: #072530;
  font-weight: 700;
}

.btn-accent:hover {
  background: var(--accent-gold-hover);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  border-color: var(--secondary);
  background: var(--bg-subtle);
}

/* Botón Exportar Hero - Siempre Texto e Icono Blanco */
.btn-hero-export {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.45);
  color: #FFFFFF !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-weight: 600;
}

.btn-hero-export:hover {
  background: rgba(255, 255, 255, 0.28);
  border-color: #FFFFFF;
  color: #FFFFFF !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.btn-hero-export svg {
  color: #FFFFFF !important;
  stroke: #FFFFFF !important;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-whatsapp {
  background: #25D366;
  color: #FFFFFF;
}

.btn-whatsapp:hover {
  background: #1EBE5D;
}

.btn-danger {
  background: #EF4444;
  color: #FFFFFF;
}

.btn-danger:hover {
  background: #DC2626;
}

/* Buscador y Filtros */
.search-filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  flex: 1;
  min-width: 260px;
  position: relative;
}

.search-input-wrapper svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 46px;
  padding: 0 16px 0 44px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(78, 135, 140, 0.2);
}

.filter-select {
  height: 46px;
  padding: 0 16px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.filter-select:focus {
  outline: none;
  border-color: var(--secondary);
}

/* ==========================================================================
   TARJETAS Y TABLAS DE DATOS
   ========================================================================== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
  transition: all 0.3s ease;
}

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

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

[data-theme="dark"] .card-title {
  color: #FFFFFF;
}

/* Grid de Pacientes / Tarjetas */
.patients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.patient-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  transition: all 0.25s ease;
  position: relative;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.patient-card:hover {
  border-color: var(--secondary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.patient-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
  background: var(--bg-subtle);
}

.patient-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.patient-card-name {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}

[data-theme="dark"] .patient-card-name {
  color: #FFFFFF;
}

.patient-card-dni {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
}

.patient-badge-os {
  background: var(--secondary-light);
  color: var(--secondary);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(78, 135, 140, 0.3);
}

.patient-card-body {
  font-size: 0.88rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.patient-card-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.patient-card-footer {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   LÍNEA DE TIEMPO / FICHERO DE CONSULTAS
   ========================================================================== */
.timeline-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}

.timeline-entry {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
  position: relative;
  border-left: 5px solid var(--secondary);
}

.timeline-entry:hover {
  border-color: var(--secondary);
  box-shadow: var(--shadow-md);
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.timeline-patient-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.timeline-date {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--primary);
  font-size: 1rem;
}

[data-theme="dark"] .timeline-date {
  color: #FFFFFF;
}

.timeline-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-imc-normal { background: var(--badge-normal-bg); color: var(--badge-normal-text); }
.badge-imc-warning { background: var(--badge-warning-bg); color: var(--badge-warning-text); }
.badge-imc-danger { background: var(--badge-danger-bg); color: var(--badge-danger-text); }

.timeline-grid-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 12px;
  padding: 14px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
}

.detail-block {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--secondary);
}

.detail-value {
  color: var(--text-main);
  white-space: pre-line;
}

.timeline-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  justify-content: flex-end;
}

/* ==========================================================================
   TABLA DE OBRAS SOCIALES
   ========================================================================== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

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

.custom-table th {
  background: var(--primary);
  color: #FFFFFF;
  padding: 14px 16px;
  font-family: var(--font-heading);
  font-weight: 600;
  letter-spacing: 0.5px;
  font-size: 0.85rem;
}

.custom-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  background: var(--bg-card);
}

.custom-table tr:hover td {
  background: var(--bg-subtle);
}

/* ==========================================================================
   MODALES CLÍNICOS
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 37, 48, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 30px 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

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

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 680px;
  width: 100%;
  margin: auto;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px) scale(0.97);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: visible;
  position: relative;
}

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

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-subtle);
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
}

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

[data-theme="dark"] .modal-title {
  color: #FFFFFF;
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: visible;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--bg-subtle);
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
}

/* Formularios Clínicos */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.form-label .helper {
  font-size: 0.75rem;
  color: var(--secondary);
  font-weight: normal;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(78, 135, 140, 0.15);
}

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

/* Calculadora IMC dentro del formulario */
.imc-calculator-card {
  background: var(--bg-subtle);
  border: 1px dashed var(--secondary);
  border-radius: var(--radius-md);
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-items: flex-end;
}

.imc-result-badge {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--secondary);
}

/* ==========================================================================
   BARRA DE NAVEGACIÓN INFERIOR MÓVIL (APP NATIVA)
   ========================================================================== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: var(--bg-card-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  z-index: 99;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  padding: 0 8px;
}

.mobile-nav-item {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font-heading);
  cursor: pointer;
  flex: 1;
  height: 100%;
  transition: all 0.2s ease;
}

.mobile-nav-item.active {
  color: var(--primary);
}

[data-theme="dark"] .mobile-nav-item.active {
  color: var(--secondary);
}

.mobile-fab-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: #FFFFFF;
  border: 3px solid var(--bg-card);
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transform: translateY(-16px);
  transition: all 0.25s ease;
}

.mobile-fab-btn:active {
  transform: translateY(-12px) scale(0.95);
}

/* Toast Notificaciones */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (max-width: 768px) {
  .toast-container {
    bottom: calc(var(--bottom-nav-height) + 16px);
    right: 16px;
    left: 16px;
  }
}

.toast {
  background: var(--primary);
  color: #FFFFFF;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideUp 0.3s ease;
  border-left: 4px solid var(--accent-gold);
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   RECETA MÉDICA IMPRIMIBLE & WHATSAPP
   ========================================================================== */
.prescription-sheet {
  background: #FFFFFF;
  color: #1A2E35;
  padding: 32px;
  border-radius: var(--radius-md);
  border: 1px solid #DEEAE8;
  box-shadow: var(--shadow-sm);
  font-family: var(--font-body);
}

.prescription-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.prescription-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.prescription-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
}

.prescription-doctor-name {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}

.prescription-doctor-spec {
  font-size: 0.85rem;
  color: var(--secondary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.prescription-patient-card {
  background: #F4F8F7;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  font-size: 0.88rem;
}

.prescription-content {
  min-height: 180px;
  font-size: 1rem;
  line-height: 1.8;
  white-space: pre-line;
  padding: 10px 0;
}

.prescription-footer {
  margin-top: 40px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-top: 1px dashed #B8CDD4;
  padding-top: 20px;
}

.prescription-signature-box {
  text-align: center;
  width: 200px;
  border-top: 1px solid #1A2E35;
  padding-top: 6px;
  font-size: 0.82rem;
  font-weight: 600;
}

/* ==========================================================================
   REGLAS PARA IMPRESIÓN DIRECTA (@media print)
   ========================================================================== */
@media print {
  body {
    background: #FFFFFF !important;
    color: #000000 !important;
    padding: 0 !important;
  }

  .main-header,
  .hero-banner,
  .search-filter-bar,
  .desktop-nav,
  .mobile-bottom-nav,
  .btn,
  .card-header,
  .modal-header .btn-icon,
  .modal-footer,
  .toast-container,
  #view-pacientes,
  #view-obras-sociales,
  #view-fichero {
    display: none !important;
  }

  .modal-overlay {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    opacity: 1 !important;
    pointer-events: auto !important;
  }

  .modal-box {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    max-height: none !important;
    transform: none !important;
  }

  .prescription-sheet {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    width: 100% !important;
  }
}

/* ==========================================================================
   RESPONSIVIDAD MÓVIL
   ========================================================================== */
@media (max-width: 768px) {
  .desktop-nav {
    display: none;
  }

  .mobile-bottom-nav {
    display: flex;
  }

  .hero-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
  }

  .hero-actions {
    width: 100%;
  }

  .hero-actions .btn {
    flex: 1;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .imc-calculator-card {
    grid-template-columns: 1fr;
  }

  .modal-overlay {
    padding: 12px;
    align-items: flex-start;
  }

  .modal-box {
    border-radius: var(--radius-lg);
    margin-top: 10px;
    margin-bottom: 30px;
    max-height: none;
  }

  .prescription-patient-card {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   PAGINACIÓN DE PACIENTES
   ========================================================================== */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 0.88rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pagination-info strong {
  color: var(--primary);
  font-weight: 700;
}

[data-theme="dark"] .pagination-info strong {
  color: var(--secondary);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-pagination {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.86rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-pagination:hover:not(:disabled) {
  border-color: var(--secondary);
  color: var(--secondary);
  background: rgba(78, 135, 140, 0.08);
}

.btn-pagination:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: var(--border-color);
}

.btn-pagination-current {
  padding: 8px 12px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: var(--radius-md);
}

[data-theme="dark"] .btn-pagination-current {
  color: #FFFFFF;
  background: rgba(78, 135, 140, 0.25);
}

/* ==========================================================================
   NAVEGADOR MENSUAL DEL FICHERO DE CONSULTAS
   ========================================================================== */
.month-navigator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(13, 59, 76, 0.04) 0%, rgba(78, 135, 140, 0.08) 100%);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  gap: 12px;
  flex-wrap: wrap;
}

[data-theme="dark"] .month-navigator {
  background: rgba(255, 255, 255, 0.03);
}

.month-nav-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.month-nav-btn:hover {
  border-color: var(--secondary);
  color: var(--secondary);
  background: rgba(78, 135, 140, 0.08);
}

.month-nav-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  text-transform: capitalize;
}

[data-theme="dark"] .month-nav-label {
  color: #FFFFFF;
}

.month-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-toggle-all {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.month-toggle-all.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

.month-today-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--secondary);
  background: rgba(78, 135, 140, 0.1);
  color: var(--secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.month-today-btn:hover {
  background: var(--secondary);
  color: #FFFFFF;
}

.search-active-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(78, 135, 140, 0.12);
  border-left: 4px solid var(--secondary);
  border-radius: 4px;
  font-size: 0.86rem;
  color: var(--primary);
  margin-bottom: 14px;
}

[data-theme="dark"] .search-active-banner {
  color: #FFFFFF;
}
