/* MediMemo Premium Style Sheet */

/* --- CSS Variable Declarations & Design System --- */
:root {
  --bg-main: #0b0f19;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-card-hover: rgba(31, 41, 55, 0.8);
  --bg-input: #1f2937;
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-inverse: #0b0f19;

  /* Premium Harmony Palette */
  --primary: #818cf8;         /* Indigo (WCAG AA compliant on dark) */
  --primary-hover: #6366f1;
  --primary-glow: rgba(129, 140, 248, 0.15);
  
  --success: #10b981;         /* Emerald Green for Taken */
  --success-glow: rgba(16, 185, 129, 0.15);
  
  --warning: #f59e0b;         /* Amber for Upcoming/Pending */
  --warning-glow: rgba(245, 158, 11, 0.15);
  
  --danger: #f43f5e;          /* Rose Red for Missed */
  --danger-glow: rgba(244, 63, 94, 0.15);
  
  --info: #0ea5e9;            /* Sky Blue for details */
  --info-glow: rgba(14, 165, 233, 0.15);

  --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-glow-success: 0 0 15px rgba(16, 185, 129, 0.2);
  --shadow-glow-warning: 0 0 15px rgba(245, 158, 11, 0.2);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

body {
  font-family: var(--font-stack);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Glassmorphism utility */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-premium);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* --- Layout Architecture --- */
.app-container {
  display: flex;
  flex: 1;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
}

/* Desktop Sidebar Nav */
.sidebar {
  width: 260px;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  border-right: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, var(--primary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-icon {
  color: var(--primary);
  filter: drop-shadow(0 0 8px var(--primary));
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
}

.nav-item {
  width: 100%;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  padding: 0.85rem 1rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
}

.nav-btn i, .nav-btn svg {
  width: 20px;
  height: 20px;
  transition: transform 0.2s;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.nav-btn:hover svg {
  transform: translateX(3px);
}

.nav-btn.active {
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.2);
  font-weight: 600;
}

.nav-btn.active svg {
  color: var(--primary);
  filter: drop-shadow(0 0 4px var(--primary));
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 2.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding-bottom: 6rem; /* extra spacing for mobile navbar */
}

/* Header Component */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.welcome-section h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, #ffffff 60%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-section p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.header-widgets {
  display: flex;
  gap: 1rem;
}

.header-widget-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
}

.streak-card {
  background: var(--warning-glow);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--warning);
}

.streak-card svg {
  filter: drop-shadow(0 0 4px var(--warning));
  animation: pulse-slow 2s infinite;
}

.adherence-card {
  background: var(--success-glow);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--success);
}

/* Navigation Drawer for Mobile */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding: 0 1rem;
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  flex: 1;
  height: 100%;
  transition: all 0.2s ease;
}

.mobile-nav-btn svg {
  width: 22px;
  height: 22px;
}

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

.mobile-nav-btn.active svg {
  transform: translateY(-2px);
  filter: drop-shadow(0 0 6px var(--primary));
}

/* --- Panel Layouts & Navigation --- */
.view-panel {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.view-panel.active {
  display: block;
}

/* --- Today's Schedule Screen (Quick Log) --- */
.tracker-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

/* Calendar horizontal selector */
.date-selector-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.date-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.date-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.calendar-strip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.25rem;
  scrollbar-width: none;
}
.calendar-strip::-webkit-scrollbar {
  display: none;
}

.calendar-day-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 50px;
  padding: 0.75rem 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.calendar-day-btn:hover {
  background: rgba(255, 255, 255, 0.03);
}

.calendar-day-btn.active {
  background: var(--primary-glow);
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.3);
  font-weight: 700;
}

.calendar-day-btn .day-num {
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

.calendar-day-btn .day-lbl {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.current-date-display {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-main);
  text-align: center;
}

/* Section Header (Schedule times like "Morning", "Night") */
.schedule-section {
  margin-bottom: 2rem;
}

.schedule-section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.schedule-section-title svg {
  width: 18px;
  height: 18px;
}

/* Dose cards */
.doses-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.dose-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.dose-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--warning);
}

.dose-card.taken::before {
  background: var(--success);
}

.dose-card.missed::before {
  background: var(--danger);
}

.dose-card:hover {
  transform: translateY(-2px);
  background: var(--bg-card-hover);
}

.dose-info-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.med-color-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

.dose-details {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.dose-med-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.dose-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.meta-item svg {
  width: 14px;
  height: 14px;
}

/* Intake status badge */
.status-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.status-badge.pending {
  background: var(--warning-glow);
  color: var(--warning);
}

.status-badge.taken {
  background: var(--success-glow);
  color: var(--success);
}

.status-badge.missed {
  background: var(--danger-glow);
  color: var(--danger);
}

/* Logging Button - MOBILE EXTREMELY BIG ACTION */
.log-action-btn {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 48px; /* Finger friendly */
}

.log-action-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.03);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.log-action-btn.btn-taken-state {
  background: var(--success-glow);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
  box-shadow: none;
}

.log-action-btn.btn-taken-state:hover {
  background: rgba(16, 185, 129, 0.2);
  transform: none;
}

.log-action-btn.btn-missed-state {
  background: var(--danger-glow);
  color: var(--danger);
  border: 1px solid rgba(244, 63, 94, 0.3);
  box-shadow: none;
}

.log-action-btn.btn-missed-state:hover {
  background: rgba(244, 63, 94, 0.2);
  transform: none;
}

/* Empty checklist state style */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-muted);
  gap: 1rem;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.25rem;
  color: var(--text-main);
  font-weight: 700;
}

.empty-state p {
  max-width: 320px;
  font-size: 0.9rem;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* --- Medicine Management Screen --- */
.medicines-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

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

.med-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
}

.med-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.med-name-dosage h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.25rem;
}

.med-name-dosage span {
  font-size: 0.9rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
}

.med-card-actions {
  display: flex;
  gap: 0.5rem;
}

.med-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.med-action-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
}

.med-action-btn.btn-delete:hover {
  color: var(--danger);
  background: var(--danger-glow);
}

.med-card-details {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.detail-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.detail-line svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.med-card-times {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.time-pill {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: var(--primary);
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.time-pill svg {
  width: 12px;
  height: 12px;
}

/* --- Analytics Screen --- */
.analytics-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-box {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-box-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-box-value {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
}

.stat-box-trend {
  font-size: 0.75rem;
  font-weight: 700;
}

.stat-box-trend.up {
  color: var(--success);
}
.stat-box-trend.down {
  color: var(--danger);
}

/* Charts Containers */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

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

.chart-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.chart-wrapper {
  position: relative;
  height: 280px;
  width: 100%;
}

/* --- Modal Overlays & Forms --- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 1.5rem;
  animation: fadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  padding: 2rem;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.5rem;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

/* Form Styles */
.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

input, select, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: #fff;
  font-family: var(--font-stack);
  font-size: 0.95rem;
  transition: all 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Custom time input adding list */
.time-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.time-chip {
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.2);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.time-chip-remove {
  background: transparent;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-weight: 700;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.time-chip-remove:hover {
  color: var(--danger);
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.85rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Custom Dialog Modal (Time taken selection) */
.custom-log-modal {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.custom-time-selectors {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.custom-time-btn {
  width: 100%;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s;
}

.custom-time-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}

.custom-time-btn.active {
  background: var(--primary-glow);
  border-color: var(--primary);
  color: var(--primary);
}

/* Settings utility section */
.settings-section-card {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.settings-title {
  font-weight: 700;
  color: #fff;
  font-size: 1rem;
}

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

/* --- Dynamic Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes pulse-slow {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

/* --- Mobile Responsiveness Breakpoints --- */

@media (max-width: 900px) {
  .app-container {
    flex-direction: column;
  }
  
  .sidebar {
    display: none; /* Hide desktop sidebar */
  }
  
  .mobile-nav {
    display: flex; /* Show bottom bar navigation */
    background: rgba(11, 15, 25, 0.95); /* Deeper overlay */
    border-top: 1px solid rgba(255, 255, 255, 0.05);
  }
  
  .main-content {
    padding: 1.25rem 1rem 6rem 1rem;
    gap: 1.25rem;
  }
  
  /* Distraction-Free Mobile Tracker Styles */
  #panel-tracker .date-selector-bar,
  #panel-tracker #calendar-strip-container,
  .dashboard-header {
    display: none !important; /* Hide header, widgets, calendar by default on mobile */
  }
  
  /* Show headers/calendars only when mobile focus is explicitly expanded */
  body.show-mobile-details #panel-tracker .date-selector-bar,
  body.show-mobile-details #panel-tracker #calendar-strip-container,
  body.show-mobile-details .dashboard-header {
    display: flex !important;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  /* Large finger-friendly checklist adjustments */
  .schedule-section-title {
    font-size: 1.2rem;
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
  }
  
  .dose-card {
    padding: 1.5rem 1.25rem;
    border-radius: var(--radius-lg);
    background: rgba(22, 30, 49, 0.85); /* Slightly solid card */
  }
  
  .dose-med-name {
    font-size: 1.3rem;
  }
  
  .dose-meta {
    font-size: 0.95rem;
    gap: 1rem;
    margin-top: 0.5rem;
  }
  
  .log-action-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    border-radius: var(--radius-md);
  }
  
  /* Focus mode toggle pill */
  .focus-toggle-container {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
    margin-bottom: 1rem;
  }
  
  .focus-toggle-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
  }
  
  .focus-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
  }
}

@media (max-width: 480px) {
  /* Extra compact spacing for mobile trackers */
  .dose-card {
    padding: 1.5rem 1.25rem;
    flex-direction: column;
    align-items: stretch;
    gap: 1.25rem;
  }
  
  .log-action-btn {
    width: 100%;
    justify-content: center;
  }
}

/* --- Floating Undo Snackbar/Toast --- */
.toast-container {
  position: fixed;
  bottom: 85px; /* Neatly above the mobile bottom tab bar (70px height + 15px gap) */
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 90%;
  max-width: 400px;
  pointer-events: none;
}

.toast-card {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  background: rgba(17, 24, 39, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.6), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-card.fade-out {
  opacity: 0;
  transform: scale(0.9) translateY(10px);
}

.toast-message {
  font-size: 0.9rem;
  font-weight: 500;
  color: #fff;
  line-height: 1.4;
  flex: 1;
}

.toast-undo-btn {
  background: var(--warning-glow);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
  min-height: 44px;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.toast-undo-btn:hover {
  background: rgba(245, 158, 11, 0.25);
  border-color: var(--warning);
  transform: scale(1.03);
}

.toast-dismiss-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.toast-dismiss-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

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

/* Adjust toast container and layout parameters for desktop viewports */
@media (min-width: 901px) {
  .toast-container {
    bottom: 2rem;
    left: auto;
    right: 2rem;
    transform: none;
    max-width: 360px;
  }
  
  @keyframes toastSlideUp {
    from {
      opacity: 0;
      transform: translateY(20px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

/* --- Unified Time-Slot Group Cards --- */
.slot-card {
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  margin-bottom: 1rem;
}

.slot-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--warning); /* Default pending amber */
  transition: background 0.3s ease;
}

.slot-card.taken::before {
  background: var(--success); /* Green if all are taken */
}

.slot-card.missed::before {
  background: var(--danger); /* Red if all are missed */
}

.slot-card:hover {
  transform: translateY(-2px);
  background: var(--bg-card-hover);
}

.slot-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.slot-time-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
}

.slot-time-badge svg, .slot-time-badge i {
  width: 18px;
  height: 18px;
  color: var(--primary);
  filter: drop-shadow(0 0 3px var(--primary));
}

.slot-header-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.slot-status-summary {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-slot-options {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-slot-options:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.btn-slot-options svg, .btn-slot-options i {
  width: 16px;
  height: 16px;
}

.slot-medicines-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.slot-med-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}

.slot-med-line:hover {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.06);
}

.slot-med-info-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.slot-med-details {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.slot-med-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.slot-med-dose-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.slot-med-dose-meta span {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.slot-med-dose-meta svg, .slot-med-dose-meta i {
  width: 12px;
  height: 12px;
}

.slot-med-right-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* --- Premium Custom Checkboxes --- */
.custom-checkbox {
  display: inline-block;
  position: relative;
  width: 22px;
  height: 22px;
  cursor: pointer;
  user-select: none;
}

.custom-checkbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 22px;
  width: 22px;
  background-color: rgba(255, 255, 255, 0.03);
  border: 1.5px solid var(--border-subtle);
  border-radius: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.custom-checkbox:hover input ~ .checkmark {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.custom-checkbox input:checked ~ .checkmark {
  background-color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.custom-checkbox input:checked ~ .checkmark:after {
  display: block;
}

.custom-checkbox .checkmark:after {
  left: 7px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Custom Checkbox Status Icons for Completed Intake Rows */
.slot-med-status-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.slot-med-status-icon.taken {
  background: var(--success-glow);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.slot-med-status-icon.taken svg, .slot-med-status-icon.taken i {
  width: 14px;
  height: 14px;
}

.slot-med-status-icon.missed {
  background: var(--danger-glow);
  color: var(--danger);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.slot-med-status-icon.missed svg, .slot-med-status-icon.missed i {
  width: 14px;
  height: 14px;
}

/* --- Group Slot Footer Logging Button --- */
.slot-footer {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.btn-group-log {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.5rem;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 48px; /* Finger-friendly touch height */
}

.btn-group-log:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: scale(1.015);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-group-log:disabled {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* Finger-friendly tap scaling adjustments inside lines */
@media (max-width: 900px) {
  .slot-card {
    padding: 1.5rem 1.25rem;
    border-radius: var(--radius-lg);
    background: rgba(22, 30, 49, 0.85); /* Slightly solid card */
  }
  
  .slot-med-line {
    padding: 1rem;
    border-radius: var(--radius-lg);
  }
  
  .slot-med-name {
    font-size: 1.15rem;
  }
  
  .slot-med-dose-meta {
    font-size: 0.9rem;
    margin-top: 0.15rem;
  }
  
  .btn-group-log {
    padding: 1rem;
    font-size: 1.05rem;
  }
}

/* --- Skipped State Visual Styling --- */
.slot-card.skipped::before {
  background: var(--text-muted); /* Grey border indicator if whole slot is skipped */
}

.slot-med-line.skipped {
  opacity: 0.6;
  background: rgba(255, 255, 255, 0.01);
  border-color: rgba(255, 255, 255, 0.03);
}

.slot-med-line.skipped:hover {
  background: rgba(255, 255, 255, 0.015);
}

.status-badge.skipped {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.slot-med-status-icon.skipped {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.slot-med-status-icon.skipped svg, .slot-med-status-icon.skipped i {
  width: 13px;
  height: 13px;
  opacity: 0.8;
}

/* --- Skip Reason Modal & Predefined Chips --- */
.reason-chips-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.reason-chip-btn {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-family: var(--font-stack);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.reason-chip-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.reason-chip-btn.selected {
  background: var(--warning-glow);
  border-color: var(--warning);
  color: var(--warning);
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.15);
}

/* Scrollbar for chips grid if needed */
.reason-chips-grid::-webkit-scrollbar {
  width: 4px;
}
.reason-chips-grid::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.05);
}

@media (max-width: 480px) {
  .reason-chips-grid {
    max-height: 180px;
  }
}

/* --- SW Update Banner --- */
.sw-update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: rgba(99, 102, 241, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-stack);
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sw-update-banner button {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-sm);
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  font-family: var(--font-stack);
  white-space: nowrap;
}

.sw-update-banner button:hover {
  background: rgba(255, 255, 255, 0.35);
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}


/* --- Accessibility: respect reduced-motion preference --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* The hidden attribute must win over class display rules (e.g. .empty-state's flex) */
[hidden] {
  display: none !important;
}

/* --- Inline form field errors --- */
.field-error {
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 0.4rem;
}

#form-medicine input[aria-invalid="true"] {
  border-color: var(--danger);
}
