/* ============================================================
   MASANTÉ — CSS Principal
   Design médical moderne, sobre, rassurant
   Thème clair & sombre | Mobile-first
   ============================================================ */

/* ---- Variables ---- */
:root {
  --blue:       #4A90D9;
  --blue-light: #EBF4FF;
  --blue-dark:  #2C6FAC;
  --green:      #5CB85C;
  --green-light:#EDF7ED;
  --orange:     #F0AD4E;
  --orange-light:#FFF8EC;
  --red:        #D9534F;
  --red-light:  #FFF0EF;
  --purple:     #9B59B6;
  --purple-light:#F5EEFB;
  --teal:       #1ABC9C;

  --bg:         #F4F7FB;
  --surface:    #FFFFFF;
  --surface2:   #F0F4FA;
  --border:     #E2E8F4;
  --text-primary:   #1A2340;
  --text-secondary: #5A6A8A;
  --text-muted:     #8B9DC0;

  --topbar-h:   60px;
  --bottomnav-h:70px;
  --radius:     16px;
  --radius-sm:  10px;
  --radius-lg:  24px;
  --shadow:     0 4px 20px rgba(74,144,217,0.10);
  --shadow-md:  0 8px 32px rgba(74,144,217,0.15);
  --transition: 0.22s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="dark"] {
  --bg:         #0F1623;
  --surface:    #1A2340;
  --surface2:   #1F2B44;
  --border:     #2A3A5C;
  --text-primary:   #E8EEF9;
  --text-secondary: #8BA4C8;
  --text-muted:     #4A6080;
  --blue-light: #1A2E4A;
  --green-light:#142A14;
  --orange-light:#2A200A;
  --red-light:  #2A100F;
  --purple-light:#1E1030;
  --shadow:     0 4px 20px rgba(0,0,0,0.35);
  --shadow-md:  0 8px 32px rgba(0,0,0,0.45);
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-tap-highlight-color: transparent; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; color: var(--text-primary); background: var(--surface); }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ---- Utility ---- */
.hidden { display: none !important; }
.text-center { text-align: center; }

/* ============================================================
   SPLASH SCREEN
   ============================================================ */
#splash-screen {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(145deg, #4A90D9, #2C6FAC);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
#splash-screen.fade-out { opacity: 0; visibility: hidden; }
.splash-content { text-align: center; color: #fff; }
.splash-icon { font-size: 64px; margin-bottom: 16px; animation: pulse 1.5s infinite; }
.splash-content h1 { font-size: 36px; font-weight: 800; letter-spacing: -1px; }
.splash-content p { font-size: 15px; opacity: 0.85; margin-top: 6px; }
.splash-loader {
  width: 160px; height: 4px; background: rgba(255,255,255,0.3);
  border-radius: 2px; margin: 24px auto 0; overflow: hidden;
}
.splash-bar {
  height: 100%; width: 0;
  background: #fff; border-radius: 2px;
  animation: loadbar 1.8s ease forwards;
}
@keyframes loadbar { from { width:0 } to { width:100% } }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.08)} }

/* ============================================================
   LAYOUT
   ============================================================ */
#app {
  max-width: 480px; margin: 0 auto;
  min-height: 100dvh; position: relative;
  display: flex; flex-direction: column;
}

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 4px; min-width: 80px; }
.topbar-right { justify-content: flex-end; }
.topbar-center { flex: 1; text-align: center; }
.app-title {
  font-size: 18px; font-weight: 700;
  color: var(--blue); letter-spacing: -0.5px;
}
.app-title i { margin-right: 4px; }

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--bottomnav-h) + 16px);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ---- Pages ---- */
.page { display: none; padding: 16px; animation: pageIn 0.3s ease; }
.page.active { display: block; }
@keyframes pageIn {
  from { opacity:0; transform:translateY(8px) }
  to   { opacity:1; transform:translateY(0) }
}
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h2 {
  font-size: 24px; font-weight: 700; letter-spacing: -0.5px;
}
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }

/* ---- Bottom Nav ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: var(--bottomnav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-around;
  padding: 0 4px;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px;
  padding: 8px 4px;
  color: var(--text-muted);
  font-size: 10px; font-weight: 500;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
  position: relative;
}
.nav-btn i { font-size: 20px; transition: transform var(--transition); }
.nav-btn.active { color: var(--blue); }
.nav-btn.active i { transform: scale(1.15); }
.nav-btn.active::before {
  content: '';
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 32px; height: 3px; border-radius: 0 0 3px 3px;
  background: var(--blue);
}
.nav-btn:active { background: var(--surface2); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--blue); color: #fff;
  border-radius: var(--radius-sm);
  padding: 12px 20px; font-size: 15px; font-weight: 600;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  box-shadow: 0 4px 14px rgba(74,144,217,0.35);
}
.btn-primary:hover { background: var(--blue-dark); transform: translateY(-1px); }
.btn-primary:active { transform: scale(0.97); }

.btn-outline {
  display: inline-flex; align-items: center; gap: 6px;
  border: 2px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 10px 16px; font-size: 14px; font-weight: 500;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.btn-outline:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.btn-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); font-size: 17px;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.btn-icon:hover, .btn-icon:active { background: var(--surface2); color: var(--blue); }

.btn-link {
  font-size: 13px; font-weight: 600; color: var(--blue);
  background: none; padding: 4px 0;
}
.btn-add { padding: 8px 16px; font-size: 14px; }

/* Notification badge */
.notif-badge {
  position: absolute; top: 4px; right: 4px;
  background: var(--red); color: #fff;
  font-size: 9px; font-weight: 700;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--surface);
  transition: transform var(--transition);
}

/* ============================================================
   TABS
   ============================================================ */
.tab-bar {
  display: flex; gap: 4px; margin-bottom: 16px;
  background: var(--surface2); border-radius: var(--radius-sm);
  padding: 4px;
}
.tab-btn {
  flex: 1; padding: 9px 6px; border-radius: 8px;
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  transition: all var(--transition); text-align: center;
}
.tab-btn.active {
  background: var(--surface); color: var(--blue);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: pageIn 0.25s ease; }

/* ============================================================
   DASHBOARD CARDS
   ============================================================ */
.summary-cards {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-bottom: 24px;
}
.summary-card {
  border-radius: var(--radius);
  padding: 16px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; transition: transform var(--transition), box-shadow var(--transition);
}
.summary-card:active { transform: scale(0.97); }
.card-blue  { background: var(--blue-light); }
.card-green { background: var(--green-light); }
.card-orange{ background: var(--orange-light); }
.card-purple{ background: var(--purple-light); }
.summary-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.card-blue   .summary-icon { background: var(--blue);   color: #fff; }
.card-green  .summary-icon { background: var(--green);  color: #fff; }
.card-orange .summary-icon { background: var(--orange); color: #fff; }
.card-purple .summary-icon { background: var(--purple); color: #fff; }
.summary-number { display: block; font-size: 22px; font-weight: 800; line-height: 1; }
.summary-label  { font-size: 11px; color: var(--text-secondary); font-weight: 500; margin-top: 3px; }

/* ============================================================
   SECTION BLOCKS
   ============================================================ */
.section-block {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.section-title-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-title-row h3 {
  font-size: 15px; font-weight: 700; color: var(--text-primary);
}
.section-title-row h3 i { margin-right: 6px; color: var(--blue); }

/* ============================================================
   MED TIMELINE (prises du jour)
   ============================================================ */
.med-timeline { display: flex; flex-direction: column; gap: 8px; }
.med-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
  transition: all var(--transition);
}
.med-item.taken  { opacity: 0.5; }
.med-item.missed { border-left: 3px solid var(--red); }
.med-dot {
  width: 40px; height: 40px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; flex-shrink: 0;
}
.med-info { flex: 1; }
.med-name  { font-size: 14px; font-weight: 700; }
.med-sub   { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.med-time  { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.med-actions { display: flex; gap: 4px; }
.btn-taken   { padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 600;
               background: var(--green-light); color: var(--green); }
.btn-taken:hover { background: var(--green); color: #fff; }
.btn-skip    { padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 600;
               background: var(--orange-light); color: var(--orange); }
.btn-skip:hover { background: var(--orange); color: #fff; }

/* ============================================================
   CARDS LIST (RDV, Examens, Médocs)
   ============================================================ */
.card-list { display: flex; flex-direction: column; gap: 12px; }

.appt-card, .exam-card, .med-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition);
}
.appt-card:active, .exam-card:active, .med-card:active { transform: scale(0.98); }

/* Appointment card */
.appt-card { border-left: 4px solid var(--blue); }
.appt-card.completed { border-left-color: var(--green); opacity: 0.7; }
.appt-card.cancelled { border-left-color: var(--text-muted); opacity: 0.5; }
.card-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.card-main { flex: 1; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.card-sub   { font-size: 13px; color: var(--text-secondary); }
.card-meta  { font-size: 12px; color: var(--text-muted); margin-top: 6px;
              display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.card-meta i{ color: var(--blue); }
.card-badge {
  padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700;
  white-space: nowrap;
}
.badge-upcoming { background: var(--blue-light);   color: var(--blue); }
.badge-done     { background: var(--green-light);  color: var(--green); }
.badge-pending  { background: var(--orange-light); color: var(--orange); }
.badge-cancelled{ background: var(--surface2);     color: var(--text-muted); }
.card-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.btn-call { padding: 7px 12px; border-radius: 8px; font-size: 12px; font-weight: 600;
            background: var(--green-light); color: var(--green); display: flex; align-items: center; gap: 5px; }
.btn-call:hover { background: var(--green); color: #fff; }
.btn-map  { padding: 7px 12px; border-radius: 8px; font-size: 12px; font-weight: 600;
            background: var(--blue-light); color: var(--blue); display: flex; align-items: center; gap: 5px; }
.btn-map:hover { background: var(--blue); color: #fff; }
.btn-edit { padding: 7px 12px; border-radius: 8px; font-size: 12px; font-weight: 600;
            background: var(--surface2); color: var(--text-secondary); }
.btn-edit:hover { background: var(--border); }
.btn-delete { padding: 7px 12px; border-radius: 8px; font-size: 12px; font-weight: 600;
              background: var(--red-light); color: var(--red); }
.btn-delete:hover { background: var(--red); color: #fff; }

/* Exam card */
.exam-card { border-left: 4px solid var(--purple); }
.exam-card.done { border-left-color: var(--green); }

/* Med card (list all) */
.med-card { display: flex; align-items: center; gap: 14px; }
.med-card-dot {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 20px; flex-shrink: 0;
}
.med-card-info { flex: 1; }
.med-card-name { font-size: 15px; font-weight: 700; }
.med-card-sub  { font-size: 12px; color: var(--text-secondary); margin-top: 3px; }
.med-card-actions { display: flex; gap: 4px; }
.toggle-active {
  width: 36px; height: 20px; border-radius: 10px;
  background: var(--border); position: relative; cursor: pointer;
  transition: background var(--transition);
}
.toggle-active.on { background: var(--green); }
.toggle-active::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  transition: transform var(--transition);
}
.toggle-active.on::after { transform: translateX(16px); }

/* ============================================================
   HISTORY LIST
   ============================================================ */
.history-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  margin-bottom: 6px;
}
.history-item.taken  { background: var(--green-light); }
.history-item.missed { background: var(--red-light); }
.history-item.postponed { background: var(--orange-light); }
.history-icon { font-size: 16px; flex-shrink: 0; }
.history-item.taken    .history-icon { color: var(--green); }
.history-item.missed   .history-icon { color: var(--red); }
.history-item.postponed .history-icon { color: var(--orange); }
.history-text { flex: 1; font-size: 13px; font-weight: 500; }
.history-time { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   STATS
   ============================================================ */
.stats-card {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.stats-card h4 { font-size: 14px; font-weight: 700; margin-bottom: 14px; color: var(--text-secondary); }

/* ============================================================
   PROFILE
   ============================================================ */
.profile-hero {
  text-align: center; padding: 24px 16px;
  background: linear-gradient(135deg, var(--blue-light), var(--surface2));
  border-radius: var(--radius-lg); margin-bottom: 20px;
}
.profile-avatar { font-size: 64px; color: var(--blue); margin-bottom: 8px; }
.profile-name   { font-size: 20px; font-weight: 700; }
.profile-blood  { font-size: 14px; color: var(--red); font-weight: 600; margin-top: 4px; }

.profile-sections { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.profile-section {
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.section-header-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; cursor: pointer;
  font-size: 15px; font-weight: 700; color: var(--text-primary);
  user-select: none;
}
.section-header-row i:first-child { color: var(--blue); margin-right: 8px; }
.toggle-icon { transition: transform var(--transition); color: var(--text-muted); font-size: 13px; }
.section-header-row.open .toggle-icon { transform: rotate(180deg); }
.section-body { padding: 0 16px; max-height: 600px; overflow: hidden; transition: max-height 0.35s ease, padding 0.35s ease; }
.section-body.collapsed { max-height: 0; padding: 0 16px; }
.section-body > button { margin: 12px 0; }

.profile-field { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.profile-field:last-of-type { border-bottom: none; }
.profile-field-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.profile-field-value { font-size: 14px; color: var(--text-primary); margin-top: 3px; line-height: 1.5; }

.qr-section { margin-top: 8px; }
.btn-emergency-full {
  width: 100%; padding: 16px;
  background: linear-gradient(135deg, var(--red), #C0392B);
  color: #fff; border-radius: var(--radius);
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 4px 16px rgba(217,83,79,0.35);
  transition: transform var(--transition), box-shadow var(--transition);
}
.btn-emergency-full:active { transform: scale(0.97); }

/* ============================================================
   DISCLAIMER
   ============================================================ */
.disclaimer-box {
  background: var(--blue-light); border: 1px solid var(--blue);
  border-radius: var(--radius-sm); padding: 12px 14px;
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 8px; font-size: 12px; color: var(--text-secondary);
  line-height: 1.5;
}
.disclaimer-box i { color: var(--blue); margin-top: 2px; flex-shrink: 0; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center; padding: 32px 16px;
  color: var(--text-muted);
}
.empty-state i { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(10,18,40,0.6);
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(4px);
  animation: overlayIn 0.2s ease;
}
@keyframes overlayIn { from{opacity:0} to{opacity:1} }

.modal {
  width: 100%; max-width: 480px;
  background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 92dvh;
  display: flex; flex-direction: column;
  animation: slideUp 0.3s cubic-bezier(0.4,0,0.2,1);
  overflow: hidden;
}
@keyframes slideUp { from{transform:translateY(100%)} to{transform:translateY(0)} }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-body {
  overflow-y: auto; padding: 20px;
  flex: 1; -webkit-overflow-scrolling: touch;
}
.modal-footer {
  display: flex; gap: 10px; padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-footer .btn-outline { flex: 1; justify-content: center; }
.modal-footer .btn-primary { flex: 2; justify-content: center; }

/* Emergency modal */
.modal-emergency .emergency-header {
  background: linear-gradient(135deg, var(--red), #C0392B);
  color: #fff; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: none;
}
.modal-emergency .emergency-header h3 { color: #fff; }
.modal-emergency .emergency-header .btn-icon { color: rgba(255,255,255,0.8); }
.emergency-info { margin-bottom: 20px; }
.emergency-info-row { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.emergency-info-row:last-child { border-bottom: none; }
.emergency-info-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.emergency-info-value { font-size: 15px; font-weight: 600; margin-top: 2px; }
.emergency-actions { display: flex; flex-direction: column; gap: 10px; }
.btn-emergency-action {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; border-radius: var(--radius);
  background: var(--red); color: #fff;
  font-size: 16px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(217,83,79,0.3);
  transition: transform var(--transition);
}
.btn-emergency-action:active { transform: scale(0.97); }
.btn-fire { background: #E67E22; box-shadow: 0 4px 12px rgba(230,126,34,0.3); }
.btn-euro { background: var(--blue); box-shadow: 0 4px 12px rgba(74,144,217,0.3); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
input[type=text], input[type=date], input[type=time], input[type=tel],
input[type=number], select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--surface2);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(74,144,217,0.15);
  background: var(--surface);
}
textarea { resize: vertical; min-height: 80px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235A6A8A' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

.schedule-inputs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.schedule-time { width: auto; padding: 8px 12px; font-size: 14px; }

/* Color picker */
.color-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.color-dot {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid transparent; transition: transform var(--transition), border-color var(--transition);
}
.color-dot:hover, .color-dot.active { transform: scale(1.2); border-color: var(--text-primary); }

/* Biomarker inputs */
.biomarker-row {
  display: grid; grid-template-columns: 2fr 1fr 1fr auto;
  gap: 6px; margin-bottom: 6px; align-items: end;
}
.biomarker-row input { font-size: 13px; padding: 9px 10px; }
.btn-remove-bio {
  padding: 9px 12px; background: var(--red-light); color: var(--red);
  border-radius: var(--radius-sm); font-size: 13px;
}
.bio-label { font-size: 10px; color: var(--text-muted); margin-bottom: 2px; }

/* Profile Edit */
.profile-edit-group { margin-bottom: 14px; }
.profile-edit-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }

/* ============================================================
   NOTIFICATIONS LIST
   ============================================================ */
.notif-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
  margin-bottom: 8px;
}
.notif-item.notif-urgent { border-left: 3px solid var(--red); background: var(--red-light); }
.notif-item.notif-warning { border-left: 3px solid var(--orange); background: var(--orange-light); }
.notif-item.notif-info { border-left: 3px solid var(--blue); background: var(--blue-light); }
.notif-icon { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.notif-urgent  .notif-icon { color: var(--red); }
.notif-warning .notif-icon { color: var(--orange); }
.notif-info    .notif-icon { color: var(--blue); }
.notif-text { flex: 1; }
.notif-title { font-size: 14px; font-weight: 600; }
.notif-sub   { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ============================================================
   CHARTS
   ============================================================ */
.chart-container { position: relative; }
.biomarker-selector {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
}
.biomarker-selector label { font-size: 13px; font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.biomarker-selector select { flex: 1; }
.biomarker-ref-lines {
  display: flex; align-items: center; justify-content: center;
  gap: 16px; margin-top: 10px;
}
.ref-normal { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--green); }

/* QR Info */
.qr-info { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; text-align: center; }
.qr-disclaimer { font-size: 12px; color: var(--text-muted); margin-top: 12px; text-align: center; }

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed; bottom: calc(var(--bottomnav-h) + 16px); left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--text-primary); color: var(--bg);
  padding: 12px 20px; border-radius: 50px;
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 900;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success #toast-icon { color: var(--green); }
.toast.error   #toast-icon { color: var(--red); }
.toast.info    #toast-icon { color: var(--blue); }

/* ============================================================
   RESPONSIVE (très large écrans ou desktop)
   ============================================================ */
@media (min-width: 481px) {
  .modal { border-radius: var(--radius-lg); max-height: 88vh; }
  .modal-overlay { align-items: center; }
  #app { box-shadow: 0 0 40px rgba(0,0,0,0.15); }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  animation: spin 0.7s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   DATE GROUP HEADERS (history)
   ============================================================ */
.date-group-header {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 8px 0 4px;
}

/* ============================================================
   BOUTONS DE PRISE — GROS, VISIBLES, ANIMÉS
   ============================================================ */
.med-item {
  transition: all var(--transition);
}
.med-actions {
  display: flex; flex-direction: column; gap: 6px; flex-shrink: 0;
}
.btn-taken {
  padding: 10px 14px; border-radius: 10px;
  font-size: 13px; font-weight: 700;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 3px 10px rgba(92,184,92,0.35);
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  min-width: 72px;
}
.btn-taken:hover  { background: #48a348; transform: scale(1.04); }
.btn-taken:active { transform: scale(0.96); }

.btn-skip {
  padding: 8px 14px; border-radius: 10px;
  font-size: 12px; font-weight: 600;
  background: var(--orange-light); color: var(--orange);
  border: 1.5px solid var(--orange);
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: all var(--transition);
  min-width: 72px;
}
.btn-skip:hover  { background: var(--orange); color: #fff; }
.btn-skip:active { transform: scale(0.96); }

/* Confirmation animée */
.taken-check {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  color: var(--green); font-size: 13px; font-weight: 700;
  animation: popIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes popIn {
  from { transform: scale(0.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}
.med-item.taken {
  background: var(--green-light) !important;
  border-color: var(--green) !important;
  opacity: 1 !important;
}
.med-item.taken .med-name { color: var(--green); }

/* Med item layout ajusté */
.med-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 12px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
}
.med-info { flex: 1; min-width: 0; }
.med-time {
  font-size: 15px; font-weight: 700; color: var(--blue);
  white-space: nowrap; flex-shrink: 0;
}

/* ============================================================
   CYCLES ON / OFF
   ============================================================ */

/* Toggle switch */
.toggle-label-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; cursor: pointer;
}
.toggle-label-row span { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.switch { position: relative; display: inline-block; width: 48px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: var(--border);
  border-radius: 13px; transition: background var(--transition);
  cursor: pointer;
}
.slider::before {
  content: ''; position: absolute; width: 20px; height: 20px;
  bottom: 3px; left: 3px; background: #fff; border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.switch input:checked + .slider { background: var(--blue); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* Cycle fields container */
.cycle-fields {
  background: var(--blue-light);
  border: 1.5px solid var(--blue);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 4px;
  animation: pageIn 0.25s ease;
}
.cycle-info-box {
  font-size: 12px; color: var(--blue);
  background: rgba(74,144,217,0.12);
  border-radius: var(--radius-sm); padding: 8px 12px;
  margin-bottom: 14px; display: flex; align-items: flex-start; gap: 8px;
  line-height: 1.4;
}
.cycle-reminders { margin-top: 12px; }
.cycle-reminder-title {
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 8px;
}
.checkbox-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; padding: 8px 0;
  cursor: pointer; color: var(--text-primary);
}
.checkbox-label input[type=checkbox] {
  width: 18px; height: 18px; accent-color: var(--blue);
  flex-shrink: 0; cursor: pointer;
}

/* Carte de cycle (dashboard & page médicaments) */
.cycle-card {
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.cycle-card.cycle-on  { background: var(--green-light);  border-left: 5px solid var(--green); }
.cycle-card.cycle-off { background: var(--orange-light); border-left: 5px solid var(--orange); }

.cycle-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.cycle-card-title {
  font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px;
}
.cycle-card.cycle-on  .cycle-card-title { color: var(--green); }
.cycle-card.cycle-off .cycle-card-title { color: var(--orange); }

.cycle-badge {
  padding: 4px 12px; border-radius: 20px;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.cycle-on  .cycle-badge { background: var(--green);  color: #fff; }
.cycle-off .cycle-badge { background: var(--orange); color: #fff; }

.cycle-progress-wrap {
  margin: 10px 0 6px;
}
.cycle-progress-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-secondary); margin-bottom: 6px;
}
.cycle-progress-bar {
  height: 10px; background: var(--border); border-radius: 5px; overflow: hidden;
}
.cycle-progress-fill {
  height: 100%; border-radius: 5px;
  transition: width 0.6s cubic-bezier(0.4,0,0.2,1);
}
.cycle-on  .cycle-progress-fill { background: var(--green); }
.cycle-off .cycle-progress-fill { background: var(--orange); }

.cycle-weeks-row {
  display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap;
}
.cycle-week-dot {
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  border: 2px solid var(--border);
  color: var(--text-muted); background: var(--surface);
  transition: all var(--transition);
}
.cycle-week-dot.done  { background: var(--green);  color: #fff; border-color: var(--green); }
.cycle-week-dot.current.on  { background: var(--blue); color: #fff; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(74,144,217,0.3); }
.cycle-week-dot.current.off { background: var(--orange); color: #fff; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(240,173,78,0.3); }
.cycle-week-dot.off   { background: var(--orange-light); color: var(--orange); border-color: var(--orange); }
.cycle-week-dot.future{ opacity: 0.35; }

.cycle-off-actions {
  margin-top: 14px; display: flex; flex-direction: column; gap: 8px;
}
.btn-cycle-action {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 700;
  transition: transform var(--transition), box-shadow var(--transition);
  border: none; width: 100%; text-align: left; cursor: pointer;
}
.btn-cycle-action:active { transform: scale(0.97); }
.btn-cycle-bloodtest {
  background: var(--red-light); color: var(--red);
  border: 1.5px solid var(--red);
}
.btn-cycle-bloodtest:hover { background: var(--red); color: #fff; }
.btn-cycle-appt {
  background: var(--purple-light); color: var(--purple);
  border: 1.5px solid var(--purple);
}
.btn-cycle-appt:hover { background: var(--purple); color: #fff; }

/* Section cycles wrapper */
.cycles-section {
  background: var(--surface); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.cycles-section-title {
  font-size: 15px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 14px; display: flex; align-items: center; gap: 8px;
}
.cycles-section-title i { color: var(--blue); }

/* Prise en pause (semaine OFF) */
.med-item.cycle-paused {
  opacity: 0.55;
  background: var(--orange-light) !important;
  border-color: var(--orange) !important;
}
.med-item.cycle-paused .med-name::after {
  content: ' — PAUSE';
  font-size: 10px; font-weight: 700; color: var(--orange);
  background: var(--orange-light); padding: 2px 6px;
  border-radius: 4px; margin-left: 6px;
}

/* Cycle toggle group dans le form */
.cycle-toggle-group { margin-top: 4px; }

/* Badge pause sur med-item */
.cycle-pause-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 10px; border-radius: 8px;
  background: var(--orange-light); color: var(--orange);
  font-size: 12px; font-weight: 700;
  border: 1.5px solid var(--orange);
}

/* ============================================================
   POSOLOGIE — Fiche détaillée médicament
   ============================================================ */

/* Pill counter badge (ex: "3 comprimés") */
.posologie-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 700;
  background: var(--blue-light); color: var(--blue);
  border: 1.5px solid var(--blue);
  white-space: nowrap;
}
.posologie-badge i { font-size: 11px; }

/* Sur le med-item (liste du jour) */
.med-posologie-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 4px; flex-wrap: wrap;
}

/* Pastilles de comprimés animées */
.pill-visual {
  display: flex; gap: 3px; align-items: center; flex-wrap: wrap;
}
.pill-dot {
  width: 14px; height: 14px; border-radius: 50%;
  display: inline-block;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform 0.15s ease;
}
.pill-dot:hover { transform: scale(1.3); }

/* Instruction badge */
.instruction-badge {
  font-size: 11px; color: var(--text-muted);
  display: flex; align-items: center; gap: 4px;
}
.instruction-badge i { color: var(--orange); }

/* Fiche complète d'un médicament (modal détail) */
.med-detail-sheet {
  padding: 4px 0;
}
.med-detail-header {
  display: flex; align-items: center; gap: 14px; margin-bottom: 20px;
}
.med-detail-icon {
  width: 60px; height: 60px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: #fff; flex-shrink: 0;
}
.med-detail-name  { font-size: 20px; font-weight: 800; }
.med-detail-dosage{ font-size: 14px; color: var(--text-secondary); margin-top: 2px; }

.posologie-block {
  background: var(--blue-light);
  border: 1.5px solid var(--blue);
  border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.posologie-block-title {
  font-size: 12px; font-weight: 800; color: var(--blue);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}
.posologie-line {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.posologie-line:last-child { border-bottom: none; padding-bottom: 0; }
.posologie-line-label { color: var(--text-secondary); font-weight: 500; }
.posologie-line-value { font-weight: 700; color: var(--text-primary); text-align: right; }
.posologie-line-value .pill-visual { justify-content: flex-end; }

/* Grand affichage posologie quotidienne */
.posologie-daily {
  background: var(--surface2); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px;
  border: 1px solid var(--border);
}
.posologie-daily-title {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;
}
.posologie-schedule-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; margin-bottom: 6px;
  background: var(--surface); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.posologie-schedule-time {
  font-size: 18px; font-weight: 800; color: var(--blue);
  min-width: 52px; flex-shrink: 0;
}
.posologie-schedule-info { flex: 1; }
.posologie-schedule-qty {
  font-size: 14px; font-weight: 700; color: var(--text-primary);
}
.posologie-schedule-sub {
  font-size: 12px; color: var(--text-muted); margin-top: 2px;
}

/* Notes/instructions dans la fiche */
.med-detail-notes {
  background: var(--orange-light);
  border: 1.5px solid var(--orange);
  border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 13px;
  color: var(--text-secondary); line-height: 1.6;
  display: flex; gap: 10px; align-items: flex-start;
}
.med-detail-notes i { color: var(--orange); margin-top: 2px; flex-shrink: 0; }

/* Med-card enrichie */
.med-card-posologie {
  margin-top: 6px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

/* Bouton "Voir la fiche" */
.btn-fiche {
  padding: 6px 12px; border-radius: 8px; font-size: 12px; font-weight: 600;
  background: var(--blue-light); color: var(--blue);
  border: 1.5px solid var(--blue);
  display: inline-flex; align-items: center; gap: 5px;
  transition: all var(--transition);
}
.btn-fiche:hover { background: var(--blue); color: #fff; }

