/* ============================================================
   AGENDA DG — Stylesheet
   Design: Corporate / Premium / Minimaliste
   ============================================================ */

/* ── Variables (ARP — Agence sénégalaise de Réglementation pharmaceutique) */
:root {
  /* Brand colours — ARP charte officielle */
  --brand-900: #1f4a35;        /* vert très foncé (sidebar) */
  --brand-800: #2a6244;        /* vert foncé (hover) */
  --brand-700: #337A57;        /* vert ARP foncé (primary actions) */
  --brand-600: #46AA77;        /* vert ARP moyen (highlights) */
  --brand-50:  #ecf7f0;        /* vert très clair (backgrounds) */
  --gold:      #E9C155;        /* doré ARP */
  --gold-lt:   #FBF5AD;        /* doré clair ARP */

  /* Backwards-compat aliases (do not edit consumers further) */
  --navy-900: var(--brand-900);
  --navy-800: var(--brand-800);
  --navy-700: var(--brand-700);
  --navy-600: var(--brand-600);

  /* Semantic */
  --color-confirmed:  #2a6244;
  --color-pending:    #d68910;
  --color-cancelled:  #a93226;
  --color-urgent:     #922b21;
  --color-important:  #1a5276;
  --color-normal:     #2a6244;

  /* Neutrals */
  --bg:       #f0f2f5;
  --surface:  #ffffff;
  --border:   #dde1e7;
  --text:     #1a1a2e;
  --muted:    #6b7280;

  /* Sizing */
  --sidebar-w:   240px;
  --header-h:    64px;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.14);

  /* Typography */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

/* Ensure HTML hidden attribute always hides, even against display:flex rules */
[hidden] { display: none !important; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--navy-700); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, box-shadow .15s, opacity .15s;
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary   { background: var(--navy-700); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-600); }

.btn-gold      { background: var(--gold); color: var(--navy-900); font-weight: 600; }
.btn-gold:hover:not(:disabled) { background: var(--gold-lt); }

.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled) { border-color: var(--navy-700); background: #f5f7fb; }

.btn-ghost     { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }

.btn-danger    { background: #c0392b; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a93226; }

.btn-success   { background: var(--color-confirmed); color: #fff; }
.btn-success:hover:not(:disabled) { background: #145a32; }

.btn-sm { padding: 5px 12px; font-size: .8125rem; }
.btn-icon { padding: 8px; border-radius: 6px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Form elements ──────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-label { font-size: .8125rem; font-weight: 500; color: var(--text); }
.form-label .required { color: #c0392b; margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9375rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(27,58,107,.12);
}
.form-input::placeholder { color: #9ca3af; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { appearance: none; 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 d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

.input-password-wrap { position: relative; }
.input-password-wrap .form-input { padding-right: 44px; }
.btn-toggle-pwd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); padding: 4px; border-radius: 4px;
}
.btn-toggle-pwd:hover { color: var(--text); }
.btn-toggle-pwd:focus-visible { outline: 2px solid var(--gold); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 16px;
}
.alert-error   { background: #fdeded; border: 1px solid #fca5a5; color: #991b1b; }
.alert-success { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }
.alert-info    { background: #eff6ff; border: 1px solid #93c5fd; color: #1e3a8a; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-confirmed  { background: #d1fae5; color: #065f46; }
.badge-pending    { background: #fef3c7; color: #92400e; }
.badge-cancelled  { background: #fee2e2; color: #991b1b; }
.badge-urgent     { background: #fee2e2; color: #991b1b; }
.badge-important  { background: #dbeafe; color: #1e3a8a; }
.badge-normal     { background: #d1fae5; color: #065f46; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body { background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%); }

.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  gap: 24px;
}

.login-brand {
  display: flex;
  justify-content: center;
  width: 100%;
}
.login-logo-img {
  height: 130px;
  width: auto;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,.30));
}

.login-tagline {
  text-align: center;
  color: #fff;
  max-width: 520px;
  padding: 0 16px;
}
.login-org {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: #fff;
  margin-bottom: 4px;
  line-height: 1.3;
}
.login-title {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.25;
  color: var(--gold-lt);
}
.login-subtitle {
  font-size: .8rem;
  color: rgba(255,255,255,.6);
  margin-top: 8px;
  font-weight: 400;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
}

.pwd-strength {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin-top: 6px;
  transition: background .2s;
  position: relative;
  overflow: hidden;
}
.pwd-strength.weak::after,
.pwd-strength.medium::after,
.pwd-strength.strong::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  border-radius: 2px;
  transition: width .2s, background .2s;
}
.pwd-strength.weak::after   { width: 33%; background: #e74c3c; }
.pwd-strength.medium::after { width: 66%; background: #f39c12; }
.pwd-strength.strong::after { width: 100%; background: #27ae60; }

.pwd-rules {
  list-style: none;
  margin: 12px 0 18px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: .8rem;
}
.pwd-rules li {
  position: relative;
  padding-left: 22px;
  margin: 4px 0;
  color: var(--muted);
  transition: color .15s;
}
.pwd-rules li::before {
  content: '○';
  position: absolute; left: 0;
  color: var(--muted);
}
.pwd-rules li.valid {
  color: #1a7f4b;
}
.pwd-rules li.valid::before {
  content: '✓';
  color: #1a7f4b;
  font-weight: 700;
}

.login-credentials {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.login-hint { font-size: .8rem; color: var(--muted); margin-bottom: 10px; }

.credential-grid { display: flex; flex-direction: column; gap: 6px; }
.credential-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .8125rem; }
.credential-role { color: var(--muted); min-width: 140px; }
.credential-item code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: .8rem; color: var(--navy-700); }

.login-footer {
  color: rgba(255,255,255,.4);
  font-size: .75rem;
  text-align: center;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy-900);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform .25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
  background: rgba(255,255,255,.08);
  padding: 4px;
  border-radius: 8px;
}
.sidebar-app-name { font-size: .9rem; font-weight: 600; color: #fff; line-height: 1.2; }
.sidebar-app-sub  { font-size: .7rem; color: rgba(255,255,255,.5); }

.sidebar-user {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--navy-700);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .875rem;
  font-weight: 700;
  color: var(--gold);
  flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name { font-size: .8125rem; font-weight: 600; color: #fff; truncate: ellipsis; white-space: nowrap; overflow: hidden; }
.sidebar-user-role { font-size: .7125rem; color: var(--gold); margin-top: 1px; }
.sidebar-user-wrap { display: flex; align-items: center; gap: 10px; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  padding: 10px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: .875rem;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
  width: 100%;
  text-align: left;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--gold); color: var(--navy-900); font-weight: 600; }
.nav-item.active svg { color: var(--navy-900); }
.nav-item:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ── Top header ──────────────────────────────────────────────── */
.app-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-header {
  position: sticky;
  top: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 30;
  gap: 16px;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-page-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.header-breadcrumb { font-size: .8rem; color: var(--muted); }

.header-right { display: flex; align-items: center; gap: 8px; }

.hamburger {
  display: none;
  padding: 8px;
  border-radius: 6px;
  color: var(--text);
}
.hamburger:hover { background: var(--bg); }
.hamburger:focus-visible { outline: 2px solid var(--navy-700); }

/* ── Content area ────────────────────────────────────────────── */
.app-content { flex: 1; padding: 24px; overflow-x: hidden; }

/* ── Views ────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Dashboard stats ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
}
.stat-card.urgent    { border-color: #e74c3c; }
.stat-card.confirmed { border-color: var(--color-confirmed); }
.stat-card.pending   { border-color: var(--color-pending); }
.stat-card.total     { border-color: var(--navy-700); }

.stat-value { font-size: 2rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label { font-size: .8125rem; color: var(--muted); margin-top: 4px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}
@media (max-width: 960px) { .dashboard-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: .9375rem; font-weight: 600; color: var(--text); }
.card-body  { padding: 16px 20px; }

/* ── Appointment list items ──────────────────────────────────── */
.appt-list { display: flex; flex-direction: column; gap: 8px; }

.appt-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  background: var(--surface);
}
.appt-item:hover { border-color: var(--navy-700); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.appt-item:focus-visible { outline: 2px solid var(--navy-700); outline-offset: 2px; }

.appt-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.dot-urgent    { background: var(--color-urgent); }
.dot-important { background: var(--color-important); }
.dot-normal    { background: var(--color-confirmed); }

.appt-item-body { flex: 1; min-width: 0; }
.appt-item-title { font-size: .875rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-item-meta  { font-size: .775rem; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.appt-item-time  { display: flex; align-items: center; gap: 3px; }

.appt-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }

/* ── Calendar toolbar ─────────────────────────────────────────── */
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.calendar-nav { display: flex; align-items: center; gap: 8px; }
.calendar-period { font-size: 1rem; font-weight: 600; min-width: 200px; text-align: center; }

.view-tabs { display: flex; border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.view-tab {
  padding: 7px 16px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--muted);
  border: none;
  background: var(--surface);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.view-tab:hover   { background: var(--bg); color: var(--text); }
.view-tab.active  { background: var(--navy-700); color: #fff; }
.view-tab:focus-visible { outline: 2px solid var(--navy-700); outline-offset: -2px; }

/* ── Month calendar ───────────────────────────────────────────── */
.month-grid {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--navy-900);
}
.month-weekday {
  padding: 10px 4px;
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  color: rgba(255,255,255,.7);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.month-cells {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid var(--border);
}

.month-cell {
  min-height: 110px;
  min-width: 0;             /* allow grid columns to shrink below content */
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px;
  vertical-align: top;
  transition: background .1s;
  overflow: hidden;
}
.month-cell:nth-child(7n) { border-right: none; }
.month-cell:hover { background: #f8f9fc; }

.month-cell-num {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  margin-bottom: 4px;
}
.month-cell.today .month-cell-num {
  background: var(--navy-700);
  color: #fff;
  font-weight: 700;
}
.month-cell.other-month .month-cell-num { color: #c0c8d8; }
.month-cell.other-month { background: #fafbfc; }

.cal-event {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity .15s;
}
.cal-event:hover { opacity: .85; }
.cal-event:focus-visible { outline: 2px solid var(--text); }

.cal-event.status-confirmed { background: #d1fae5; color: #065f46; }
.cal-event.status-pending   { background: #fef3c7; color: #92400e; }
.cal-event.status-cancelled { background: #fee2e2; color: #991b1b; text-decoration: line-through; }

.cal-event.priority-urgent   .event-dot { background: #e74c3c; }
.cal-event.priority-important .event-dot { background: #3498db; }
.cal-event.priority-normal    .event-dot { background: #27ae60; }

.event-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.cal-more  { font-size: .7rem; color: var(--navy-700); padding: 2px 5px; cursor: pointer; font-weight: 600; }
.cal-more:hover { text-decoration: underline; }

/* ── Week / Day grid ──────────────────────────────────────────── */
.time-grid-wrap {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.time-col {
  width: 56px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: #fafbfc;
}
.time-slot-label {
  height: 60px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 4px 8px 0 0;
  font-size: .7rem;
  color: var(--muted);
  font-weight: 500;
}
.time-slot-label.first { height: 36px; } /* header row */

.day-col-wrap { flex: 1; display: flex; flex-direction: column; overflow-x: auto; }
.day-headers  { display: grid; border-bottom: 1px solid var(--border); }
.day-header-cell {
  padding: 8px 4px;
  text-align: center;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text);
  border-right: 1px solid var(--border);
  min-width: 100px;
}
.day-header-cell.today-col { background: var(--navy-900); color: #fff; }
.day-header-cell:last-child { border-right: none; }

.day-body { display: grid; position: relative; }
.day-col {
  border-right: 1px solid var(--border);
  position: relative;
  min-width: 100px;
}
.day-col:last-child { border-right: none; }

.time-row {
  height: 60px;
  border-bottom: 1px solid #edf0f5;
  position: relative;
}
.time-row.half-hour { border-bottom: 1px dashed #edf0f5; height: 30px; }

.tg-event {
  position: absolute;
  left: 2px; right: 2px;
  border-radius: 5px;
  padding: 3px 6px;
  font-size: .7rem;
  font-weight: 500;
  cursor: pointer;
  overflow: hidden;
  z-index: 2;
  transition: opacity .15s, box-shadow .15s;
  line-height: 1.3;
}
.tg-event:hover { opacity: .88; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.tg-event:focus-visible { outline: 2px solid var(--text); }
.tg-event.status-confirmed { background: #d1fae5; color: #065f46; border-left: 3px solid #059669; }
.tg-event.status-pending   { background: #fef3c7; color: #92400e; border-left: 3px solid #d97706; }
.tg-event.status-cancelled { background: #fee2e2; color: #991b1b; border-left: 3px solid #dc2626; text-decoration: line-through; }
.tg-event-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-event-time  { font-size: .65rem; opacity: .8; }

/* ── Appointment Detail / Modal ──────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,27,42,.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-size: 1rem; font-weight: 600; }

.modal-close {
  padding: 6px; border-radius: 6px; color: var(--muted);
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-close:focus-visible { outline: 2px solid var(--navy-700); }

.modal-body   { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ── Appointment detail view ─────────────────────────────────── */
.detail-section { margin-bottom: 18px; }
.detail-label   { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.detail-value   { font-size: .9375rem; color: var(--text); }
.detail-badges  { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-meta    { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-creator { display: flex; align-items: center; gap: 6px; font-size: .8125rem; color: var(--muted); }
.detail-creator svg { flex-shrink: 0; }

/* ── History panel ────────────────────────────────────────────── */
.history-list { display: flex; flex-direction: column; gap: 0; }
.history-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: .8125rem;
}
.history-item:last-child { border-bottom: none; }

.history-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.history-icon.created   { background: #d1fae5; color: #065f46; }
.history-icon.modified  { background: #dbeafe; color: #1e3a8a; }
.history-icon.confirmed { background: #d1fae5; color: #065f46; }
.history-icon.cancelled { background: #fee2e2; color: #991b1b; }

.history-content { flex: 1; min-width: 0; }
.history-details { color: var(--text); }
.history-appt    { color: var(--navy-700); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-time    { color: var(--muted); font-size: .75rem; margin-top: 2px; }

/* ── Toast notifications ─────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  background: var(--navy-900);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: slideLeft .2s ease;
}
@keyframes slideLeft { from { transform: translateX(20px); opacity: 0 } to { transform: translateX(0); opacity: 1 } }
.toast.toast-success { background: var(--color-confirmed); }
.toast.toast-error   { background: var(--color-urgent); }
.toast.toast-info    { background: var(--navy-700); }
.toast-msg { flex: 1; }

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--muted);
  text-align: center;
  gap: 8px;
}
.empty-state svg { opacity: .35; }
.empty-state p { font-size: .9rem; }

/* ── Spinner ────────────────────────────────────────────────── */
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg) } }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--navy-700);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* ── Sidebar overlay for mobile ──────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 39;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }

  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .sidebar-overlay.open { opacity: 1; pointer-events: auto; }

  .app-main { margin-left: 0; }
  .hamburger { display: flex; }

  .app-header { padding: 0 12px; gap: 8px; }
  .app-content { padding: 12px; }

  .header-page-title { font-size: .9rem; }

  /* Month — compact cells */
  .month-cell { min-height: 70px; padding: 4px; }
  .month-cell-num { width: 22px; height: 22px; font-size: .75rem; margin-bottom: 2px; }
  .cal-event { font-size: .62rem; padding: 1px 4px; }
  .cal-event .event-dot { display: none; }      /* save space on tiny cells */
  .cal-more { font-size: .62rem; padding: 1px 4px; }

  .month-weekday { font-size: .6rem; padding: 6px 2px; letter-spacing: 0; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.5rem; }

  .modal { max-width: 100%; max-height: 96vh; border-radius: 10px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }

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

  /* Calendar toolbar wraps */
  .calendar-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .calendar-nav     { justify-content: space-between; }
  .calendar-period  { font-size: .9rem; min-width: 0; flex: 1; text-align: center; }
  .view-tabs        { width: 100%; }
  .view-tab         { flex: 1; padding: 7px 4px; font-size: .75rem; }

  /* Time grid — give a sensible min-width and let it scroll horizontally on phone */
  .day-col-wrap { overflow-x: auto; }
  .day-headers, .day-body { min-width: 600px; }
  .time-col { width: 44px; }
  .time-slot-label { font-size: .65rem; padding-right: 4px; }

  /* Toasts on mobile — top-anchored, full width */
  .toast-container { right: 12px; left: 12px; bottom: 12px; max-width: none; }

  /* Detail meta single column */
  .detail-meta { grid-template-columns: 1fr; }

  .login-page { padding: 24px 16px; gap: 18px; }
  .login-card { padding: 24px 20px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .month-cell { min-height: 56px; padding: 3px; }
  .month-cell-num { width: 20px; height: 20px; font-size: .7rem; }
  .cal-event { font-size: .58rem; }
  .login-logo-img { height: 100px; }
  .login-org { font-size: .9rem; }
  .login-title { font-size: 1.15rem; }
}

/* ── Utility ──────────────────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.mt-16 { margin-top: 16px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Today indicator on time grid ───────────────────────────── */
.time-now-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: #e74c3c;
  z-index: 3;
  pointer-events: none;
}
.time-now-dot {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 10px; height: 10px;
  background: #e74c3c;
  border-radius: 50%;
}
