/* ==========================================================================
   MEDIALERT PRO — ULTRA-PREMIUM CLINICAL DESIGN SYSTEM & STYLING
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-primary: #070c18;
  --bg-secondary: #0d1527;
  --card-bg: rgba(18, 28, 51, 0.72);
  --card-bg-hover: rgba(26, 40, 72, 0.85);
  --card-border: rgba(148, 163, 184, 0.14);
  --card-border-glow: rgba(56, 189, 248, 0.35);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Theme Accents */
  --cyan-primary: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.3);
  --blue-primary: #3b82f6;
  --blue-glow: rgba(59, 130, 246, 0.3);
  --amber-primary: #f59e0b;
  --amber-glow: rgba(245, 158, 11, 0.3);
  --emerald-primary: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.3);
  --rose-primary: #f43f5e;
  --rose-glow: rgba(244, 63, 94, 0.3);

  /* Typography */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-display: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Elevation & Blur */
  --blur-glass: blur(18px);
  --shadow-card: 0 12px 35px -8px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--card-border);
  --shadow-glow: 0 0 30px -5px var(--cyan-glow);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
}

/* Base Reset & Core Typography */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(14, 165, 233, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 20%, rgba(16, 185, 129, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(245, 158, 11, 0.06) 0px, transparent 60%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: #1e293b;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #334155;
}

/* ==========================================================================
   HEADER NAVIGATION
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: var(--blur-glass);
  background: rgba(7, 12, 24, 0.82);
  border-bottom: 1px solid var(--card-border);
  padding: 0.75rem 1.5rem;
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--cyan-primary), var(--blue-primary));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 18px var(--cyan-glow);
}
.brand-icon svg {
  width: 26px;
  height: 26px;
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.pro-badge {
  font-size: 0.65rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--cyan-primary), var(--blue-primary));
  color: #fff;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  letter-spacing: 0.05em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.patient-pill {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--card-border);
  padding: 0.35rem 0.85rem 0.35rem 0.45rem;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.25s ease;
}
.patient-pill:hover {
  background: rgba(51, 65, 85, 0.7);
  border-color: var(--cyan-primary);
}

.patient-pill .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #06b6d4);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.patient-details {
  display: flex;
  flex-direction: column;
}

.patient-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f1f5f9;
}

.diagnosis-badge {
  font-size: 0.7rem;
  color: #38bdf8;
}

/* Sync Status Badge (Mobile <-> PC real-time) */
.sync-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #34d399;
  letter-spacing: 0.02em;
  transition: all 0.3s ease;
  user-select: none;
}
.sync-status-badge .sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
  transition: background 0.3s ease;
}
.sync-status-badge.syncing {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
  color: #38bdf8;
}
.sync-status-badge.syncing .sync-dot {
  background: #38bdf8;
  box-shadow: 0 0 10px #38bdf8;
  animation: pulse-dot 0.8s infinite alternate;
}
.sync-status-badge.offline {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #f87171;
}
.sync-status-badge.offline .sync-dot {
  background: #ef4444;
  box-shadow: 0 0 10px #ef4444;
}
@keyframes pulse-dot {
  from { opacity: 0.35; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.2); }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

/* Buttons */
.btn-icon {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--card-border);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-icon:hover {
  background: rgba(51, 65, 85, 0.8);
  color: var(--cyan-primary);
}
.btn-icon svg {
  width: 20px;
  height: 20px;
}

.btn-primary, .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  font-family: var(--font-sans);
}

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #2563eb);
  color: #fff;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.35);
}
.btn-primary:hover {
  box-shadow: 0 6px 22px rgba(14, 165, 233, 0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--card-border);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: rgba(51, 65, 85, 0.85);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary svg, .btn-secondary svg {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   MAIN LAYOUT & DOCTOR BANNER
   ========================================================================== */
.main-wrapper {
  max-width: 1280px;
  margin: 1.5rem auto;
  padding: 0 1.25rem 5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.doctor-banner {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: var(--blur-glass);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.doc-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(14, 165, 233, 0.15);
  color: var(--cyan-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.doc-icon svg {
  width: 20px;
  height: 20px;
}

.doc-info {
  font-size: 0.85rem;
  color: #cbd5e1;
  flex-grow: 1;
}
.doc-info strong {
  color: #fff;
}
.doc-meta {
  color: var(--text-dim);
  margin-left: 0.4rem;
}

.btn-pill-small {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--card-border);
  color: #cbd5e1;
  font-size: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.btn-pill-small:hover {
  background: var(--cyan-primary);
  color: #fff;
  border-color: var(--cyan-primary);
}

/* ==========================================================================
   HERO CARD: PRÓXIMA TOMA & CUENTA REGRESIVA
   ========================================================================== */
.hero-card {
  position: relative;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.85) 0%, rgba(13, 21, 39, 0.9) 100%);
  backdrop-filter: var(--blur-glass);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.7), 0 0 30px -10px rgba(14, 165, 233, 0.25);
  overflow: hidden;
}

.hero-background-glow {
  position: absolute;
  top: -50%;
  left: -20%;
  width: 140%;
  height: 200%;
  background: radial-gradient(circle at 30% 30%, rgba(14, 165, 233, 0.15) 0%, transparent 60%);
  pointer-events: none;
}

.hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #38bdf8;
  background: rgba(14, 165, 233, 0.12);
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #38bdf8;
  border-radius: 50%;
  box-shadow: 0 0 10px #38bdf8;
  animation: pulse 2s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.3); }
}

.current-clock {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: #94a3b8;
  letter-spacing: 0.05em;
}

.hero-content {
  display: grid;
  grid-template-columns: 200px 1fr;
  align-items: center;
  gap: 2.5rem;
  margin-bottom: 2rem;
}

/* Dial Circle */
.countdown-dial-wrap {
  display: flex;
  justify-content: center;
}

.countdown-circle {
  position: relative;
  width: 160px;
  height: 160px;
}

.progress-ring {
  width: 160px;
  height: 160px;
  transform: rotate(-90deg);
}

.progress-ring__circle {
  transition: stroke-dashoffset 0.5s linear;
}

.countdown-inner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.5rem;
}

.countdown-title {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #94a3b8;
}

.countdown-time {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 16px rgba(14, 165, 233, 0.6);
  margin: 0.2rem 0;
}

.countdown-target {
  font-size: 0.72rem;
  color: #38bdf8;
  font-weight: 600;
}

/* Hero Details */
.hero-details {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.next-dose-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.pill-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid var(--card-border);
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: #f1f5f9;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.pill-chip.antibiotic { border-color: rgba(56, 189, 248, 0.4); color: #38bdf8; }
.pill-chip.analgesic { border-color: rgba(245, 158, 11, 0.4); color: #fbbf24; }
.pill-chip.syrup { border-color: rgba(16, 185, 129, 0.4); color: #34d399; }

.hero-instructions {
  font-size: 0.95rem;
  color: #cbd5e1;
  line-height: 1.6;
}

.hero-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 0.5rem;
}

.btn-take-dose {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  padding: 0.85rem 1.65rem;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-display);
  cursor: pointer;
  box-shadow: 0 8px 24px -4px rgba(16, 185, 129, 0.5);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-take-dose:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -4px rgba(16, 185, 129, 0.7);
}
.btn-take-dose svg {
  width: 22px;
  height: 22px;
}

.btn-snooze {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-snooze:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #fff;
}
.btn-snooze svg {
  width: 18px;
  height: 18px;
}

/* Treatment Overall Progress */
.treatment-progress-bar-wrap {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  color: #94a3b8;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(30, 41, 59, 0.8);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #06b6d4, #10b981);
  border-radius: 9999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   MEDICINES GRID & DETAILED CARDS
   ========================================================================== */
.section-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.badge-active-treatments {
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 0.25rem 0.7rem;
  border-radius: 9999px;
}

.medicines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.med-card {
  position: relative;
  background: var(--card-bg);
  backdrop-filter: var(--blur-glass);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.65rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow-card);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.med-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.7);
}

.med-badge-type {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--card-border);
}

.med-card.antibiotic .med-badge-type { color: #38bdf8; border-color: rgba(56, 189, 248, 0.3); }
.med-card.analgesic .med-badge-type { color: #fbbf24; border-color: rgba(245, 158, 11, 0.3); }
.med-card.syrup .med-badge-type { color: #34d399; border-color: rgba(16, 185, 129, 0.3); }

.med-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.med-icon-wrap {
  width: 50px;
  height: 50px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.med-icon-wrap.blue { background: rgba(14, 165, 233, 0.15); color: #38bdf8; }
.med-icon-wrap.amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.med-icon-wrap.emerald { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.med-icon-wrap svg {
  width: 28px;
  height: 28px;
}

.med-titles h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
}
.med-dose {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #fff;
}
.med-compound {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.med-regimen {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
}

.regimen-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.regimen-item:last-child {
  grid-column: span 2;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 0.5rem;
}

.regimen-item .lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.regimen-item .val {
  font-size: 0.85rem;
  font-weight: 600;
  color: #f1f5f9;
}
.text-highlight { color: #38bdf8 !important; }
.text-amber { color: #fbbf24 !important; }
.text-emerald { color: #34d399 !important; }

.med-next-due {
  background: rgba(2, 6, 23, 0.5);
  border: 1px dashed rgba(148, 163, 184, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.due-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.due-time {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}
.due-countdown {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #38bdf8;
  font-weight: 600;
}

.med-stats {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.stat-bar {
  width: 100%;
  height: 6px;
  background: rgba(30, 41, 59, 0.8);
  border-radius: 9999px;
  overflow: hidden;
}
.stat-fill {
  height: 100%;
  background: #38bdf8;
  border-radius: 9999px;
  transition: width 0.5s ease;
}
.stat-fill.amber { background: #f59e0b; }
.stat-fill.emerald { background: #10b981; }

.days-remaining {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: right;
}

.med-warning, .med-tip {
  font-size: 0.78rem;
  line-height: 1.45;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
}
.med-warning {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.25);
  color: #fda4af;
}
.med-tip {
  background: rgba(14, 165, 233, 0.08);
  border: 1px solid rgba(14, 165, 233, 0.2);
  color: #bae6fd;
}

.btn-card-take {
  width: 100%;
  background: rgba(14, 165, 233, 0.18);
  border: 1px solid rgba(14, 165, 233, 0.4);
  color: #38bdf8;
  font-weight: 700;
  padding: 0.65rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}
.btn-card-take:hover {
  background: #0ea5e9;
  color: #fff;
  border-color: #0ea5e9;
}
.btn-card-take.amber {
  background: rgba(245, 158, 11, 0.18);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fbbf24;
}
.btn-card-take.amber:hover {
  background: #f59e0b;
  color: #fff;
}
.btn-card-take.emerald {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.4);
  color: #34d399;
}
.btn-card-take.emerald:hover {
  background: #10b981;
  color: #fff;
}

/* ==========================================================================
   TIMELINE & CRONOGRAMA INTERACTIVO
   ========================================================================== */
.day-selector {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
}

.tab-btn {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.tab-btn.active, .tab-btn:hover {
  background: rgba(14, 165, 233, 0.2);
  border-color: var(--cyan-primary);
  color: #fff;
}

.timeline-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.timeline-slot {
  background: var(--card-bg);
  backdrop-filter: var(--blur-glass);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1rem 1.35rem;
  display: grid;
  grid-template-columns: 100px 1fr auto;
  align-items: center;
  gap: 1.25rem;
  transition: all 0.2s ease;
}
.timeline-slot:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: var(--card-bg-hover);
}

.timeline-slot.past {
  opacity: 0.65;
  border-left: 4px solid #10b981;
}
.timeline-slot.next {
  border-left: 4px solid var(--cyan-primary);
  background: linear-gradient(90deg, rgba(14, 165, 233, 0.12), rgba(18, 28, 51, 0.72));
  box-shadow: 0 4px 20px rgba(14, 165, 233, 0.15);
}
.timeline-slot.upcoming {
  border-left: 4px solid rgba(148, 163, 184, 0.3);
}

.slot-time {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}
.slot-date {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.slot-meds {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.slot-tag {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.slot-tag.clamoxin { background: rgba(14, 165, 233, 0.15); color: #38bdf8; border: 1px solid rgba(14, 165, 233, 0.3); }
.slot-tag.dexketo { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.slot-tag.tusilen { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }

.slot-status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  text-align: right;
}
.slot-status-badge.taken { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.slot-status-badge.pending { background: rgba(14, 165, 233, 0.15); color: #38bdf8; }
.slot-status-badge.future { color: var(--text-dim); }

/* ==========================================================================
   BITÁCORA / TABLA DE HISTORIAL
   ========================================================================== */
.history-table-wrap {
  background: var(--card-bg);
  backdrop-filter: var(--blur-glass);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.history-table th {
  background: rgba(15, 23, 42, 0.9);
  padding: 0.85rem 1.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--card-border);
}

.history-table td {
  padding: 0.85rem 1.25rem;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
}

.history-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.btn-delete-row {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.btn-delete-row:hover {
  opacity: 1;
}

/* ==========================================================================
   MODALES
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 7, 18, 0.8);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: 100%;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.9);
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.prescription-modal-card {
  max-width: 900px;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
}
.badge-verified {
  font-size: 0.72rem;
  color: #34d399;
  font-weight: 600;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
}
.modal-close-btn:hover { color: #fff; }

.modal-body {
  padding: 1.5rem;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #cbd5e1;
}
.form-input {
  background: #1e293b;
  border: 1px solid var(--card-border);
  color: #fff;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 1rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Prescription Digital Layout */
.prescription-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.prescription-img-wrap {
  width: 100%;
  max-height: 480px;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.prescription-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.prescription-img-wrap img:hover {
  transform: scale(1.05);
}

.img-hint {
  display: block;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 0.35rem;
}

.card-paper {
  background: #f8fafc;
  color: #0f172a;
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.05);
}

.paper-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}
.paper-header h4 {
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
}
.paper-header p {
  font-size: 0.75rem;
  color: #475569;
}

.paper-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.75rem;
  font-size: 0.75rem;
  color: #334155;
  background: #f1f5f9;
  padding: 0.65rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.paper-rx-list h5 {
  font-size: 0.85rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}
.paper-rx-list ol {
  padding-left: 1.2rem;
  font-size: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  color: #1e293b;
}
.paper-rx-list li strong {
  color: #0f172a;
}
.rx-note {
  display: block;
  font-size: 0.72rem;
  color: #64748b;
  font-style: italic;
}

/* ==========================================================================
   PWA INSTALL BANNER
   ========================================================================== */
.install-prompt-banner {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120px);
  z-index: 150;
  width: calc(100% - 2rem);
  max-width: 600px;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.install-prompt-banner.active {
  transform: translateX(-50%) translateY(0);
}

.install-banner-inner {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: var(--blur-glass);
  border: 1px solid rgba(14, 165, 233, 0.3);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6), 0 0 25px rgba(14, 165, 233, 0.25);
}

.pwa-icon img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

.install-text {
  flex-grow: 1;
}
.install-text strong {
  display: block;
  font-size: 0.85rem;
  color: #fff;
}
.install-text p {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem;
}
.btn-close:hover { color: #fff; }

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--cyan-primary);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  animation: slideInToast 0.3s ease;
}

@keyframes slideInToast {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   RESPONSIVE DESIGN (MOBILE ADAPTATION)
   ========================================================================== */
@media (max-width: 860px) {
  .hero-content {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 1.5rem;
  }
  .countdown-dial-wrap {
    margin: 0 auto;
  }
  .next-dose-banner {
    justify-content: center;
  }
  .hero-action-buttons {
    justify-content: center;
  }
  .prescription-layout {
    grid-template-columns: 1fr;
  }
  .timeline-slot {
    grid-template-columns: 80px 1fr;
    gap: 0.75rem;
  }
  .slot-status-badge {
    grid-column: span 2;
    text-align: left;
  }
}

@media (max-width: 640px) {
  .app-header {
    padding: 0.6rem 1rem;
  }
  .patient-pill {
    display: none;
  }
  .btn-label {
    display: none;
  }
  .main-wrapper {
    padding: 0 0.85rem 5rem;
  }
  .hero-card {
    padding: 1.25rem;
  }
  .medicines-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   CHECKLIST SECTION & DUAL ACTION BUTTONS
   ========================================================================== */
.btn-custom-time {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(14, 165, 233, 0.15);
  border: 1px solid rgba(14, 165, 233, 0.4);
  color: #38bdf8;
  padding: 0.85rem 1.35rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-display);
  cursor: pointer;
  transition: all 0.25s ease;
}
.btn-custom-time:hover {
  background: rgba(14, 165, 233, 0.3);
  color: #fff;
  border-color: #38bdf8;
  transform: translateY(-1px);
}
.btn-custom-time svg {
  width: 20px;
  height: 20px;
}

.checklist-counter-badge {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  background: rgba(14, 165, 233, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(14, 165, 233, 0.3);
}

.checklist-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.checklist-card {
  background: var(--card-bg);
  backdrop-filter: var(--blur-glass);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1.15rem 1.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  transition: all 0.25s ease;
}
.checklist-card:hover {
  background: var(--card-bg-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.checklist-card.completed {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.3);
}

.checklist-left {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-grow: 1;
}

/* Custom Checkbox */
.checklist-check-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 2px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.8);
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.checklist-check-btn:hover {
  border-color: var(--cyan-primary);
  background: rgba(14, 165, 233, 0.15);
}
.checklist-card.completed .checklist-check-btn {
  background: #10b981;
  border-color: #10b981;
  color: #fff;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.4);
}
.checklist-check-btn svg {
  width: 22px;
  height: 22px;
}

.checklist-med-info h4 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.checklist-card.completed .checklist-med-info h4 {
  text-decoration: line-through;
  color: #94a3b8;
}

.checklist-med-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}
.checklist-time-tag {
  font-family: var(--font-mono);
  font-weight: 600;
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.06);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
}
.checklist-taken-time {
  color: #34d399;
  font-weight: 600;
}

/* Actions in Checklist Row */
.checklist-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-check-now {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}
.btn-check-now:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-check-custom {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--card-border);
  color: #cbd5e1;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.2s ease;
}
.btn-check-custom:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
}

.btn-check-undo {
  background: none;
  border: 1px dashed rgba(148, 163, 184, 0.3);
  color: #94a3b8;
  font-size: 0.75rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-check-undo:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* Dual Actions inside Medicine Cards */
.med-card-actions-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  width: 100%;
}

.btn-card-custom {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--card-border);
  color: #cbd5e1;
  font-weight: 600;
  padding: 0.65rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 0.85rem;
  text-align: center;
  transition: all 0.2s ease;
}
.btn-card-custom:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
}
.btn-card-custom.amber:hover {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.4);
}
.btn-card-custom.emerald:hover {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.4);
}

/* Quick Presets Chips in Modal */
.quick-preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.btn-preset-chip {
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid var(--card-border);
  color: #cbd5e1;
  padding: 0.35rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-preset-chip:hover {
  background: rgba(14, 165, 233, 0.2);
  border-color: var(--cyan-primary);
  color: #fff;
}

/* Calc Preview Card in Modal */
.calc-preview-card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  margin-top: 1rem;
}

.calc-preview-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 0.35rem;
}

.calc-preview-body {
  font-size: 0.82rem;
  color: #cbd5e1;
  line-height: 1.45;
}

@media (max-width: 768px) {
  .checklist-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
  }
  .checklist-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .med-card-actions-dual {
    grid-template-columns: 1fr;
  }
}

