/* ============================================================
   DOCTOR MADNESS — styles.css
   Photo-Realistic Psychiatric Phone UI
   ============================================================ */

/* ─── OFFLINE FONTS ─────────────────────────────────────────── */
/* Google Fonts loaded in <head> if online; falls back to system fonts offline */

/* ─── RESET & BASE ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --black:       #000000;
  --bg-deep:     #0a0a0f;
  --bg-dark:     #111118;
  --bg-surface:  #1a1a2e;
  --bg-raised:   #16213e;
  --bg-card:     #1e1e30;
  --bg-input:    #0f0f1a;
  --border:      #2a2a45;
  --border-lite: #333355;
  --text:        #e8e8f0;
  --text-muted:  #888899;
  --text-dim:    #555570;
  --accent:      #4a9eff;
  --accent-glow: rgba(74, 158, 255, 0.25);
  --green:       #22c55e;
  --green-glow:  rgba(34, 197, 94, 0.2);
  --red:         #ef4444;
  --red-glow:    rgba(239, 68, 68, 0.25);
  --yellow:      #eab308;
  --orange:      #f97316;
  --purple:      #a855f7;
  --pink:        #ec4899;
  --rx-cream:    #fdf8f0;
  --rx-border:   #8b7355;
  --rx-line:     #c8b89a;
  --rx-blue:     #003399;
  --phone-w:     390px;
  --sidebar-w:   280px;
  --toolbar-h:   52px;
  --radius:      12px;
  --radius-sm:   8px;
  --radius-lg:   20px;
  --shadow:      0 4px 20px rgba(0,0,0,0.6);
  --shadow-lg:   0 8px 40px rgba(0,0,0,0.8);
  --font-main:   'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:   'Courier Prime', 'Courier New', monospace;
}

html, body {
  width: 100%; height: 100%;
  font-family: var(--font-main);
  background: var(--bg-deep);
  color: var(--text);
  overflow: hidden;
  user-select: none;
}

/* ─── CANVAS LAYERS ─────────────────────────────────────────── */
#particle-canvas, #rain-canvas, #effect-overlay {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
#particle-canvas { z-index: 0; }
#rain-canvas { z-index: 1; opacity: 0; transition: opacity 0.5s; }
#effect-overlay { z-index: 9990; transition: background 0.3s; }

/* ─── SCREENS ──────────────────────────────────────────────── */
.screen {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100%;
  display: none; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 10;
}
.screen.active { display: flex; }

/* ─── MAIN MENU SCREEN ─────────────────────────────────────── */
#screen-menu {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(74,158,255,0.06) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(168,85,247,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(239,68,68,0.05) 0%, transparent 50%),
    linear-gradient(180deg, #05050d 0%, #0a0a18 50%, #0d0510 100%);
}

.menu-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  z-index: 20;
  /* keep the whole stack on screen even at 700px viewport height */
  max-height: 100vh;
  overflow-y: auto;
  padding: 12px 0 16px;
  scrollbar-width: none;
}
.menu-container::-webkit-scrollbar { display: none; }

/* ─── LOGO ──────────────────────────────────────────────────── */
.game-logo {
  text-align: center;
  margin-bottom: 14px;
}

.logo-icon {
  font-size: 3.2rem;
  display: block;
  margin-bottom: 4px;
  filter: drop-shadow(0 0 16px rgba(74,158,255,0.5));
  animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.logo-title {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #4a9eff 0%, #a855f7 50%, #ef4444 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  line-height: 1;
  margin-bottom: 3px;
}

.logo-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  letter-spacing: 2.5px;
  text-transform: uppercase;
  font-weight: 400;
}

.logo-tagline {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-style: italic;
}

/* ─── PHONE MOCK ON MENU ────────────────────────────────────── */
.menu-phone-preview {
  width: 190px;
  height: 290px;
  background: linear-gradient(160deg, #1c1c2e 0%, #13131f 100%);
  border-radius: 30px;
  border: 2px solid #2a2a45;
  box-shadow:
    0 0 0 1px #111,
    0 20px 60px rgba(0,0,0,0.8),
    inset 0 1px 0 rgba(255,255,255,0.05);
  margin: 12px 0;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.menu-phone-preview::before {
  content: '';
  position: absolute; top: 14px; left: 50%;
  transform: translateX(-50%);
  width: 70px; height: 8px;
  background: #0a0a15;
  border-radius: 10px;
  z-index: 2;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}

.menu-phone-screen {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px 16px;
  gap: 8px;
}

.preview-chat-msg {
  width: 100%;
  padding: 6px 10px;
  border-radius: 12px;
  font-size: 0.55rem;
  line-height: 1.4;
  max-width: 80%;
  animation: msgFadeIn 0.4s ease;
}

.preview-chat-msg.received {
  background: var(--bg-card);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  color: var(--text);
  border: 1px solid var(--border);
}

.preview-chat-msg.sent {
  background: linear-gradient(135deg, var(--accent), #2970d4);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  color: white;
}

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

/* ─── MENU BUTTONS ──────────────────────────────────────────── */
.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 7px;
  width: 300px;
}

.menu-btn {
  width: 100%;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu-btn::before {
  content: '';
  position: absolute; top: 0; left: -100%; right: 0; bottom: 0;
  background: rgba(255,255,255,0.06);
  transition: left 0.3s ease;
}
.menu-btn:hover::before { left: 0; }

.menu-btn-icon { font-size: 1.1rem; width: 26px; text-align: center; }

.menu-btn.primary {
  background: linear-gradient(135deg, #4a9eff 0%, #2563eb 100%);
  color: white;
  box-shadow: 0 4px 20px rgba(74,158,255,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
}
.menu-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(74,158,255,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
}

.menu-btn.secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-lite);
  box-shadow: 0 2px 10px rgba(0,0,0,0.4);
}
.menu-btn.secondary:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 4px 20px rgba(74,158,255,0.2);
}

.menu-btn.danger {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: white;
  box-shadow: 0 4px 20px rgba(239,68,68,0.3);
}
.menu-btn.danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(239,68,68,0.45);
}

.menu-btn:active { transform: translateY(0) scale(0.98); }

/* ─── HOW TO PLAY / CREDITS SCREENS ────────────────────────── */
#screen-howtoplay, #screen-credits {
  background: var(--bg-deep);
  overflow-y: auto;
  align-items: flex-start;
  justify-content: flex-start;
}

.info-screen-wrapper {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.info-screen-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.info-screen-header h1 { font-size: 2rem; font-weight: 700; }
.back-to-menu {
  margin-left: auto;
  padding: 10px 20px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-lite);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}
.back-to-menu:hover { border-color: var(--accent); color: var(--accent); }

.info-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.info-section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}

.info-section p, .info-section li {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.7;
  margin-bottom: 8px;
}

.info-section ul { list-style: none; padding: 0; }
.info-section li::before { content: '▸ '; color: var(--accent); }

.med-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.med-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.med-card-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 4px;
}
.med-card-class {
  font-size: 0.75rem;
  color: var(--accent);
  margin-bottom: 4px;
}
.med-card-uses {
  font-size: 0.73rem;
  color: var(--text-muted);
}

/* ─── CREDITS ───────────────────────────────────────────────── */
.credits-content {
  text-align: center;
  padding: 40px;
}
.credits-logo {
  font-size: 4rem;
  margin-bottom: 16px;
  display: block;
}
.credits-studio {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #4a9eff, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}
.credits-tagline {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 40px;
}
.credits-role {
  margin: 16px 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.credits-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.credits-disclaimer {
  margin-top: 40px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.78rem;
  color: var(--text-dim);
  line-height: 1.7;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ─── GAME SCREEN ───────────────────────────────────────────── */
#screen-game {
  flex-direction: column;
  background: var(--bg-deep);
  align-items: stretch;
  justify-content: flex-start;
  overflow: hidden;
}

/* ─── TOOLBAR ───────────────────────────────────────────────── */
#toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  height: var(--toolbar-h);
  z-index: 50;
  flex-shrink: 0;
}

#toolbar-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent);
  margin-right: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-btn {
  padding: 7px 14px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.tool-btn:hover {
  background: var(--bg-surface);
  border-color: var(--accent);
  color: var(--accent);
}

.tool-btn.danger {
  border-color: rgba(239,68,68,0.3);
  color: var(--red);
}
.tool-btn.danger:hover {
  background: rgba(239,68,68,0.1);
  border-color: var(--red);
}

/* ─── GAME LAYOUT ───────────────────────────────────────────── */
.game-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - var(--toolbar-h));
}

/* ─── PATIENT SIDEBAR ───────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-dark);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-header h2 {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}

#patient-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

#patient-list::-webkit-scrollbar { width: 4px; }
#patient-list::-webkit-scrollbar-track { background: transparent; }
#patient-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.patient-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s;
  border: 1px solid transparent;
  position: relative;
  margin-bottom: 4px;
}

.patient-item:hover {
  background: var(--bg-card);
  border-color: var(--border);
}

.patient-item.active {
  background: linear-gradient(135deg, rgba(74,158,255,0.12), rgba(74,158,255,0.05));
  border-color: rgba(74,158,255,0.3);
}

.patient-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg-surface);
  border: 2px solid var(--border);
}

.patient-avatar img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.avatar-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-card));
  color: var(--text-muted);
}

.status-dot {
  position: absolute;
  bottom: 2px; right: 2px;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--bg-dark);
}

.status-dot.status-normal { background: var(--green); }
.status-dot.status-angry { background: var(--orange); }
.status-dot.status-meltdown { background: var(--red); box-shadow: 0 0 8px var(--red); animation: statusPulse 1s ease-in-out infinite; }
.status-dot.status-manic { background: var(--yellow); }
.status-dot.status-crying { background: var(--accent); }
.status-dot.status-paranoid { background: var(--purple); }

@keyframes statusPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.patient-info { flex: 1; min-width: 0; }
.patient-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.patient-dx {
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.patient-mood {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.unread-badge {
  width: 20px; height: 20px;
  background: var(--red);
  color: white;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  animation: statusPulse 2s infinite;
}

/* ─── MAIN CONTENT AREA ─────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ─── PHONE FRAME WRAPPER ───────────────────────────────────── */
.phone-frame-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(74,158,255,0.04) 0%, transparent 60%),
    var(--bg-deep);
  overflow: hidden;
  position: relative;
}

/* ─── PHONE DEVICE ──────────────────────────────────────────── */
.phone-device {
  width: var(--phone-w);
  height: calc(100vh - var(--toolbar-h) - 20px);
  max-height: 820px;
  background: linear-gradient(165deg, #1c1c2a 0%, #12121e 40%, #0e0e18 100%);
  border-radius: 42px;
  border: 2px solid #2a2a42;
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.8),
    0 0 0 2px #1a1a2e,
    0 40px 100px rgba(0,0,0,0.9),
    inset 0 1px 0 rgba(255,255,255,0.07),
    inset 0 -1px 0 rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Phone notch */
.phone-device::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 120px; height: 28px;
  background: #0a0a10;
  border-radius: 0 0 20px 20px;
  z-index: 100;
}

/* Side buttons */
.phone-device::after {
  content: '';
  position: absolute;
  left: -4px; top: 120px;
  width: 4px; height: 60px;
  background: linear-gradient(180deg, #1a1a2e, #0e0e18);
  border-radius: 4px 0 0 4px;
  box-shadow: 0 -40px 0 2px #1a1a2e, 0 44px 0 2px #1a1a2e;
}

/* Status bar */
.phone-status-bar {
  height: 36px;
  padding: 8px 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  margin-top: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
  z-index: 10;
}

.status-bar-time { font-size: 0.78rem; font-weight: 700; }
.status-bar-icons { display: flex; align-items: center; gap: 6px; font-size: 0.65rem; }

/* App header */
.phone-app-header {
  padding: 8px 16px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-dark);
}

.app-header-icon { font-size: 1.3rem; }
.app-header-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
}
.app-header-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 1px;
}

#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-deep);
}

.no-chat-selected {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 0.9rem;
  flex-direction: column;
  gap: 8px;
}
.no-chat-selected p { font-size: 1rem; }

/* ─── CHAT HEADER ───────────────────────────────────────────── */
/* ── Chat Header — two-row layout so buttons never overflow ──── */
.chat-header {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 12px 6px;
  background: linear-gradient(90deg, var(--bg-dark) 0%, var(--bg-surface) 100%);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Row 1: avatar + name/status */
.chat-header-row1 {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
/* Commit button sits at the far right of row 1 */
.chat-header-row1 .commit-btn {
  margin-left: auto;
  flex-shrink: 0;
}

/* Row 2: action buttons strip */
.chat-header-row2 {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-top: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.chat-header-row2::-webkit-scrollbar { display: none; }

.chat-header-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.chat-header-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700;
  background: var(--bg-surface); color: var(--text-muted);
}

.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info h2 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
  margin-bottom: 2px;
}
/* dx + status collapsed onto ONE line, comma-separated */
.chat-header-dx {
  font-size: 0.65rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
/* hide the old separate status line — info is now in dx row */
.chat-header-status { display: none; }

/* Actions sit in row 2 — full width, scrollable if needed */
.chat-header-actions { display: none; }   /* disabled — replaced by row2 */

.hdr-btn {
  padding: 4px 9px;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.68rem;
  font-weight: 500;
  font-family: var(--font-main);
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.hdr-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── CHAT MESSAGES ─────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ─── MESSAGE BUBBLES ───────────────────────────────────────── */
.message-bubble {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 0.82rem;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
  animation: bubbleIn 0.25s ease;
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.message-bubble.sent {
  align-self: flex-end;
  background: linear-gradient(135deg, #4a9eff 0%, #2563eb 100%);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(74,158,255,0.25);
}

.message-bubble.received {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message-bubble.meltdown-msg {
  background: linear-gradient(135deg, #3d0000 0%, #200010 100%);
  border-color: rgba(239,68,68,0.4);
  color: #ffcccc;
  box-shadow: 0 2px 20px rgba(239,68,68,0.2);
}

.bubble-sender {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.bubble-text p { margin-bottom: 4px; }
.bubble-text p:last-child { margin-bottom: 0; }

.bubble-time {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.4);
  text-align: right;
  margin-top: 3px;
}

.message-bubble.received .bubble-time { color: var(--text-dim); }

/* ─── TYPING INDICATOR ──────────────────────────────────────── */
.typing-indicator {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 10px 14px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-indicator span {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingDot 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.15); }
}

/* ─── CHAT INPUT ────────────────────────────────────────────── */
.chat-input-area {
  padding: 10px 12px;
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px 12px;
  transition: border-color 0.2s;
}

.chat-input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-main);
  font-size: 0.85rem;
  line-height: 1.4;
  resize: none;
  min-height: 36px;
  max-height: 80px;
}

#chat-input::placeholder { color: var(--text-dim); }

.input-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.char-count {
  font-size: 0.68rem;
  color: var(--text-dim);
  min-width: 26px;
  text-align: right;
}

.send-btn {
  padding: 8px 14px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
  font-family: var(--font-main);
  transition: all 0.2s;
  white-space: nowrap;
}
.send-btn:hover { transform: scale(1.05); box-shadow: 0 4px 16px rgba(74,158,255,0.4); }
.send-btn:active { transform: scale(0.97); }

/* ─── QUICK REPLIES ─────────────────────────────────────────── */
.quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.quick-reply-btn {
  padding: 4px 10px;
  background: var(--bg-surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.72rem;
  font-family: var(--font-main);
  transition: all 0.15s;
}
.quick-reply-btn:hover {
  background: rgba(74,158,255,0.1);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── MODAL OVERLAY ─────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#modal-overlay.active {
  display: flex;
  animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-content {
  background: var(--bg-dark);
  border: 1px solid var(--border-lite);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: modalSlideIn 0.25s ease;
}

@keyframes modalSlideIn { from { transform: translateY(-20px) scale(0.97); } to { transform: translateY(0) scale(1); } }

.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 32px; height: 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  z-index: 10;
}
.modal-close:hover { background: var(--red); color: white; border-color: var(--red); }

/* ─── PRESCRIPTION PAD ──────────────────────────────────────── */
.rx-pad { max-width: 900px; padding: 0; overflow: hidden; }

.rx-pad-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px;
  background: linear-gradient(135deg, #1a2a1a 0%, #0f1a0f 100%);
  border-bottom: 3px solid var(--rx-border);
  position: relative;
}

.rx-logo {
  font-family: var(--font-mono);
  font-size: 3.5rem;
  font-weight: 700;
  color: #003399;
  line-height: 1;
  text-shadow: none;
  background: none;
  -webkit-text-fill-color: #003399;
  text-fill-color: #003399;
}

.rx-title { flex: 1; }
.rx-office {
  font-size: 1.1rem;
  font-weight: 700;
  color: #003399;
  font-family: var(--font-mono);
}
.rx-address, .rx-dea {
  font-size: 0.72rem;
  color: #335533;
  font-family: var(--font-mono);
  margin-top: 2px;
}

.rx-pad-body {
  background: #fdf8f0;
  padding: 20px 24px;
}

.rx-patient-info {
  display: flex;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--rx-line);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.rx-field {
  display: flex;
  gap: 6px;
  align-items: baseline;
  color: #2a2a2a;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.rx-field label {
  font-weight: 700;
  color: #444;
  white-space: nowrap;
}

.rx-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.rx-drug-list h3 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #444;
  font-family: var(--font-mono);
  margin-bottom: 10px;
  border-bottom: 1px solid var(--rx-line);
  padding-bottom: 6px;
}

.rx-class-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.rx-tab {
  padding: 3px 8px;
  background: transparent;
  border: 1px solid var(--rx-line);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: #555;
  transition: all 0.15s;
}
.rx-tab:hover, .rx-tab.active {
  background: #003399;
  color: white;
  border-color: #003399;
}

.rx-drug-scroll {
  height: 200px;
  overflow-y: auto;
  border: 1px solid var(--rx-line);
  border-radius: 6px;
  background: white;
  padding: 4px;
}

.drug-item {
  padding: 8px 10px;
  border-radius: 4px;
  cursor: pointer;
  border-bottom: 1px solid #f0e8d8;
  transition: background 0.1s;
  font-family: var(--font-mono);
}

.drug-item:hover { background: #eef4ff; }
.drug-item.selected { background: #ddeeff; border-color: #003399; }

.drug-name { font-size: 0.8rem; font-weight: 700; color: #003399; }
.drug-dose { font-size: 0.68rem; color: #555; margin-top: 1px; }
.drug-notes { font-size: 0.65rem; color: #777; margin-top: 1px; }

/* ─── PRESCRIPTION WRITE AREA ───────────────────────────────── */
.rx-write-area h3 {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #444;
  font-family: var(--font-mono);
  margin-bottom: 10px;
  border-bottom: 1px solid var(--rx-line);
  padding-bottom: 6px;
}

.rx-write-paper {
  background: white;
  border: 1px solid var(--rx-line);
  border-radius: 6px;
  padding: 16px;
  min-height: 220px;
  position: relative;
  background-image: repeating-linear-gradient(
    transparent,
    transparent 23px,
    #e8dfc8 23px,
    #e8dfc8 24px
  );
  background-size: 100% 24px;
  background-position: 0 24px;
}

.rx-symbol {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: #003399;
  margin-bottom: 8px;
  line-height: 1;
}

.rx-selected-drug {
  font-size: 0.88rem;
  color: #333;
  font-family: var(--font-mono);
  margin-bottom: 12px;
  min-height: 42px;
}

.rx-selected-drug strong { font-size: 1rem; color: #003399; }
.rx-selected-drug small { color: #555; }
.drug-uses { color: #665500; }

.rx-form-fields { display: flex; flex-direction: column; gap: 8px; }

.rx-form-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.rx-form-row label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #444;
  font-family: var(--font-mono);
  width: 80px;
  flex-shrink: 0;
  padding-top: 4px;
}

.rx-form-row input, .rx-form-row select, .rx-form-row textarea {
  flex: 1;
  background: rgba(255,255,255,0.8);
  border: 1px solid var(--rx-line);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: #333;
  outline: none;
  transition: border-color 0.15s;
}
.rx-form-row input:focus, .rx-form-row select:focus, .rx-form-row textarea:focus {
  border-color: #003399;
}
.rx-form-row textarea { resize: vertical; }

.rx-signature-line {
  margin-top: 16px;
  padding-top: 8px;
}
.rx-sig-text {
  font-family: 'Brush Script MT', cursive, var(--font-mono);
  font-size: 1.2rem;
  color: #003399;
  margin-bottom: 2px;
}
.rx-sig-underline {
  width: 200px;
  height: 1px;
  background: #444;
  margin-bottom: 2px;
}
.rx-sig-label {
  font-size: 0.65rem;
  color: #888;
  font-family: var(--font-mono);
}

.rx-send-btn {
  width: 100%;
  margin-top: 12px;
  padding: 13px;
  background: linear-gradient(135deg, #003399 0%, #0055cc 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}
.rx-send-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,51,153,0.4); }
.rx-send-btn.disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── RX SUCCESS ────────────────────────────────────────────── */
.rx-success {
  max-width: 560px;
  padding: 32px;
  text-align: center;
}

.rx-success-header { margin-bottom: 24px; }
.rx-success-icon { font-size: 3rem; margin-bottom: 8px; }
.rx-success h2 { font-size: 1.5rem; font-weight: 700; color: var(--green); }

.rx-receipt {
  background: var(--rx-cream);
  border: 1px solid var(--rx-border);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 16px;
  text-align: left;
  font-family: var(--font-mono);
}

.rx-receipt-top {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #003399;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rx-line);
}

.rx-logo-sm {
  font-size: 1.8rem;
  color: #003399;
}

.rx-receipt-fields > div {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 0.8rem;
}
.rx-receipt-fields label {
  font-weight: 700;
  color: #444;
  width: 90px;
  flex-shrink: 0;
}
.rx-receipt-fields span { color: #333; }

.rx-mail-msg {
  background: #e8f4ff;
  border: 1px solid #aaccff;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 0.78rem;
  color: #003366;
  margin-top: 14px;
  margin-bottom: 12px;
}

.rx-patient-reaction {
  font-size: 0.8rem;
  color: #444;
  background: #fff8e8;
  border: 1px solid #e8d898;
  border-radius: 6px;
  padding: 10px 12px;
  font-style: italic;
}

.rx-close-btn {
  padding: 10px 28px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}
.rx-close-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ─── MAILBOX ───────────────────────────────────────────────── */
.mailbox { max-width: 680px; padding: 0; }

.mailbox-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.mailbox-icon { font-size: 1.8rem; }
.mailbox-header h2 { font-size: 1.1rem; font-weight: 700; }

.mailbox-body { padding: 16px 24px; max-height: 70vh; overflow-y: auto; }

.mailbox-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px;
  font-size: 0.9rem;
}

.mail-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}

.mail-item-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
}

.mail-id { color: var(--text-muted); font-family: var(--font-mono); }
.mail-date { color: var(--text-dim); margin-left: auto; }
.mail-status.mail-sent { color: var(--green); font-weight: 600; }

.mail-item-body { padding: 10px 14px; font-size: 0.8rem; color: var(--text-muted); }
.mail-item-body > div { margin-bottom: 4px; }
.mail-item-body strong { color: var(--text); }

.mail-delivery-msg {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--accent);
  font-style: italic;
  border-top: 1px solid var(--border);
  padding-top: 6px;
}

/* ─── NOTEPAD / CASE NOTES ──────────────────────────────────── */
.notepad { max-width: 680px; padding: 0; }

.notepad-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, var(--bg-dark), var(--bg-surface));
}
.notepad-icon { font-size: 1.5rem; }
.notepad-header h2 { font-size: 1rem; font-weight: 700; flex: 1; }

.notepad-body {
  padding: 16px 24px;
  max-height: 75vh;
  overflow-y: auto;
}

.notepad-paper {
  background: #fffef8;
  border: 1px solid #d8c89a;
  border-radius: 6px;
  padding: 20px;
  position: relative;
  margin-bottom: 16px;
}

.notepad-top-lines {
  height: 40px;
  background: repeating-linear-gradient(
    transparent, transparent 7px,
    rgba(168,85,247,0.15) 7px, rgba(168,85,247,0.15) 8px
  );
  margin-bottom: 8px;
}

.notepad-paper::before {
  content: '';
  position: absolute;
  left: 44px; top: 0; bottom: 0;
  width: 1px;
  background: rgba(239,68,68,0.25);
}

.notepad-text {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.8;
  color: #2a2a2a;
  white-space: pre-wrap;
  word-break: break-word;
  padding-left: 52px;
}

.notepad-history h3 {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.note-detail {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}
.note-detail summary {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}
.note-detail pre {
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  white-space: pre-wrap;
  border-top: 1px solid var(--border);
}

/* ─── SCORE BOARD ───────────────────────────────────────────── */
.score-board { max-width: 420px; padding: 0; }

.score-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.score-header h2 { font-size: 1.1rem; font-weight: 700; }

.score-body { padding: 20px 24px; }

.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.score-row:last-child { border-bottom: none; }
.score-row strong { color: var(--accent); font-size: 1rem; }
.score-total { font-weight: 700; }
.score-total strong { color: var(--yellow); font-size: 1.1rem; }

/* ─── CONFIRM DIALOG ────────────────────────────────────────── */
.confirm-dialog { max-width: 440px; padding: 32px; text-align: center; }
.confirm-dialog h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 14px; }
.confirm-dialog p { color: var(--text-muted); font-size: 0.88rem; line-height: 1.6; margin-bottom: 24px; }
.confirm-buttons { display: flex; gap: 12px; justify-content: center; }
.confirm-yes {
  padding: 10px 22px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}
.confirm-yes:hover { background: #b91c1c; }
.confirm-no {
  padding: 10px 22px;
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-lite);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}
.confirm-no:hover { border-color: var(--accent); color: var(--accent); }

/* ─── TOAST NOTIFICATIONS ───────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 10px 22px;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 99999;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-warning { border-color: var(--yellow); color: var(--yellow); }
.toast.toast-error { border-color: var(--red); color: var(--red); }
.toast.toast-success { border-color: var(--green); color: var(--green); }

/* ─── ANIMATION EFFECTS ─────────────────────────────────────── */
.shake {
  animation: shakeAnim 0.5s ease-in-out;
}

@keyframes shakeAnim {
  0%, 100% { transform: translateX(0); }
  15%  { transform: translateX(-6px) rotate(-0.5deg); }
  30%  { transform: translateX(6px) rotate(0.5deg); }
  45%  { transform: translateX(-4px) rotate(-0.3deg); }
  60%  { transform: translateX(4px) rotate(0.3deg); }
  75%  { transform: translateX(-2px); }
  90%  { transform: translateX(2px); }
}

.glitch {
  animation: glitchAnim 0.4s ease;
}

@keyframes glitchAnim {
  0%, 100% { transform: skewX(0); filter: none; }
  25% { transform: skewX(4deg); filter: hue-rotate(90deg); }
  50% { transform: skewX(-4deg) translateX(3px); filter: hue-rotate(-90deg); }
  75% { transform: skewX(2deg) translateX(-2px); filter: brightness(1.3); }
}

.pulse {
  animation: pulseAnim 0.8s ease;
}

@keyframes pulseAnim {
  0% { transform: scale(1); }
  40% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ─── MAIL FLY ANIMATION ────────────────────────────────────── */
@keyframes mailFly {
  0% { transform: translateX(-50%) translateY(0) scale(1); opacity: 1; }
  100% { transform: translateX(-50%) translateY(-200px) scale(0.3); opacity: 0; }
}

/* ─── RX STAMP ──────────────────────────────────────────────── */
.rx-stamp {
  position: absolute;
  top: 20px; right: 20px;
  background: rgba(0,100,0,0.85);
  color: white;
  border: 3px solid rgba(0,80,0,0.9);
  border-radius: 4px;
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 3px;
  transform: rotate(-15deg) scale(0);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.rx-stamp.stamped { transform: rotate(-15deg) scale(1); opacity: 0.9; }

/* ─── SCROLLBARS (global) ───────────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-lite); }

/* ─── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 860px) {
  :root { --sidebar-w: 200px; --phone-w: 340px; }
  .rx-columns { grid-template-columns: 1fr; }
}

@media (max-width: 660px) {
  .sidebar { display: none; }
  :root { --phone-w: 100vw; }
  .phone-device { border-radius: 0; border-left: none; border-right: none; }
  .phone-frame-wrapper { padding: 0; }
  .logo-title { font-size: 2.4rem; }
}

/* ─── LOADING SCREEN ────────────────────────────────────────── */
#loading-screen {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  transition: opacity 0.5s;
}
#loading-screen.hidden { opacity: 0; pointer-events: none; }

.loading-spinner {
  width: 50px; height: 50px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}


/* ─── FAST FORWARD WEEK BUTTON ──────────────────────────────── */
.ff-week-btn {
  background: linear-gradient(135deg, rgba(168,85,247,0.15) 0%, rgba(74,158,255,0.1) 100%) !important;
  border-color: rgba(168,85,247,0.5) !important;
  color: #c084fc !important;
  font-weight: 600 !important;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}
.ff-week-btn::after {
  content: '';
  position: absolute;
  top: 50%; left: -100%;
  width: 60px; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(168,85,247,0.25), transparent);
  transform: translateY(-50%) skewX(-20deg);
  animation: ffShine 2.5s ease-in-out infinite;
}
@keyframes ffShine {
  0%   { left: -80px; }
  60%, 100% { left: calc(100% + 80px); }
}
.ff-week-btn:hover {
  background: linear-gradient(135deg, rgba(168,85,247,0.3) 0%, rgba(74,158,255,0.2) 100%) !important;
  border-color: #a855f7 !important;
  color: #e9d5ff !important;
  box-shadow: 0 0 18px rgba(168,85,247,0.4) !important;
}

/* ─── WEEK LOADING MODAL ─────────────────────────────────────── */
.week-loading {
  max-width: 400px;
  padding: 60px 40px;
  text-align: center;
  background: var(--bg-dark) !important;
}
.week-loading-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.week-loading-spinner {
  font-size: 3.5rem;
  animation: weekSpin 0.6s linear infinite;
}
@keyframes weekSpin {
  from { transform: rotate(0deg) scale(1); }
  50%  { transform: rotate(180deg) scale(1.15); }
  to   { transform: rotate(360deg) scale(1); }
}
.week-loading-title { font-size: 1.3rem; font-weight: 700; color: #c084fc; }
.week-loading-sub   { font-size: 0.85rem; color: var(--text-muted); }
.week-loading-dots { display: flex; gap: 6px; }
.week-loading-dots span {
  width: 8px; height: 8px;
  background: #a855f7;
  border-radius: 50%;
  animation: dotPop 1s ease-in-out infinite;
}
.week-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.week-loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPop {
  0%,80%,100% { transform: scale(1); opacity: 0.5; }
  40%         { transform: scale(1.4); opacity: 1; }
}

/* ─── WEEK REPORT MODAL ──────────────────────────────────────── */
.week-report-modal {
  max-width: 700px;
  padding: 0;
  overflow: hidden;
}
.week-report-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px;
  background: linear-gradient(90deg, var(--bg-dark), var(--bg-surface));
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}
.week-report-header h2 { font-size: 1.1rem; font-weight: 700; flex: 1; }
.week-report-body {
  max-height: calc(90vh - 70px);
  overflow-y: auto;
  padding: 20px;
}
.week-report-body::-webkit-scrollbar { width: 4px; }
.week-report-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ─── WEEK REPORT CARD ───────────────────────────────────────── */
.week-report-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.week-report-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  margin-bottom: 0;
}
.week-report-icon { font-size: 2rem; flex-shrink: 0; }
.week-report-outcome-label { font-size: 1rem; font-weight: 700; margin-bottom: 2px; }
.week-report-sub { font-size: 0.72rem; color: var(--text-muted); }

.week-report-rx-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: rgba(255,255,255,0.03);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.week-rx-pill { font-size: 1.5rem; flex-shrink: 0; }
.week-rx-name { font-size: 0.92rem; font-weight: 700; color: var(--text); }
.week-rx-dose { font-size: 0.75rem; color: var(--text-muted); margin-top: 1px; }
.week-rx-dx   { font-size: 0.72rem; color: var(--text-dim); margin-top: 1px; }

.week-report-section {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.week-report-section:last-child { border-bottom: none; }
.week-report-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.week-report-text {
  font-size: 0.84rem;
  color: var(--text-muted);
  line-height: 1.6;
  font-style: italic;
}

/* ─── PATIENT BUBBLE IN REPORT ───────────────────────────────── */
.week-report-bubble {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-top: 4px;
}
.week-report-avatar-sm {
  width: 40px; height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; color: var(--text-muted);
}
.week-report-avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
.week-bubble-name { font-size: 0.78rem; font-weight: 700; color: var(--text-muted); margin-bottom: 5px; }
.week-bubble-text { font-size: 0.86rem; color: var(--text); line-height: 1.6; }
.week-bubble-flavor {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-style: italic;
}

/* ─── HOSPITAL ALERT ─────────────────────────────────────────── */
.week-hospital-alert {
  background: rgba(220,38,38,0.08) !important;
  border-left: 3px solid #dc2626 !important;
}
.week-hospital-text {
  font-size: 0.84rem;
  color: #fca5a5;
  font-weight: 600;
  line-height: 1.5;
}

/* ─── FOLLOW-UP TEXT ─────────────────────────────────────────── */
.week-report-followup {
  font-size: 0.86rem;
  color: var(--accent);
  font-style: italic;
  padding: 10px 14px;
  background: rgba(74,158,255,0.06);
  border: 1px solid rgba(74,158,255,0.2);
  border-radius: var(--radius-sm);
}

/* ─── MOOD BARS ──────────────────────────────────────────────── */
.week-mood-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.week-mood-label { width: 44px; flex-shrink: 0; color: var(--text-dim); }
.week-mood-track {
  flex: 1;
  height: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.week-mood-before {
  height: 100%;
  background: var(--text-dim);
  border-radius: 6px;
  transition: width 0.6s ease;
}
.week-mood-after {
  height: 100%;
  border-radius: 6px;
  transition: width 0.8s ease;
}

/* ─── WEEK REPORT BUTTONS ────────────────────────────────────── */
.week-report-actions {
  display: flex;
  gap: 12px;
  padding: 16px 18px;
  border-top: 1px solid var(--border);
}
.week-btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.86rem;
  font-weight: 600;
  transition: all 0.2s;
}
.week-btn-rx {
  background: linear-gradient(135deg, #003399, #0055cc);
  color: white;
  flex: 1;
}
.week-btn-rx:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,51,153,0.4); }
.week-btn-chat {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-lite);
  flex: 1;
}
.week-btn-chat:hover { border-color: var(--accent); color: var(--accent); }


/* ─── SETTINGS PANEL ────────────────────────────────────────── */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-row label {
  font-size: 0.88rem;
  color: var(--text-muted);
}
.toggle-switch {
  width: 40px; height: 22px;
  background: var(--border);
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-switch.on { background: var(--accent); }
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  transition: left 0.2s;
}
.toggle-switch.on::after { left: 21px; }

/* ─── COMMIT BUTTON ─────────────────────────────────────────── */
.commit-btn {
  background: linear-gradient(135deg, rgba(239,68,68,0.18) 0%, rgba(220,38,38,0.10) 100%) !important;
  border: 1px solid rgba(239,68,68,0.45) !important;
  color: #fca5a5 !important;
  font-weight: 600 !important;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.commit-btn:hover {
  background: linear-gradient(135deg, rgba(239,68,68,0.30) 0%, rgba(220,38,38,0.20) 100%) !important;
  border-color: #ef4444 !important;
  color: #fff !important;
  box-shadow: 0 0 16px rgba(239,68,68,0.40) !important;
  transform: translateY(-1px);
}

/* Pulsing glow when SI/HI crisis detected */
.commit-btn-alert {
  background: linear-gradient(135deg, rgba(239,68,68,0.35) 0%, rgba(220,38,38,0.22) 100%) !important;
  border-color: #ef4444 !important;
  color: #fff !important;
  animation: commitPulse 1.4s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(239,68,68,0.6);
}
@keyframes commitPulse {
  0%   { box-shadow: 0 0 0 0   rgba(239,68,68,0.7); }
  50%  { box-shadow: 0 0 0 8px rgba(239,68,68,0);   }
  100% { box-shadow: 0 0 0 0   rgba(239,68,68,0.7); }
}

/* Waiting state (hold in progress) */
.commit-btn-waiting {
  background: linear-gradient(135deg, rgba(234,179,8,0.18) 0%, rgba(202,138,4,0.10) 100%) !important;
  border-color: rgba(234,179,8,0.45) !important;
  color: #fde047 !important;
  animation: waitingBlink 1.8s ease-in-out infinite;
  cursor: default !important;
}
@keyframes waitingBlink {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.55; }
}

/* Done state (results ready) */
.commit-btn-done {
  background: linear-gradient(135deg, rgba(74,158,255,0.20) 0%, rgba(59,130,246,0.12) 100%) !important;
  border-color: rgba(74,158,255,0.55) !important;
  color: #93c5fd !important;
  animation: none !important;
}
.commit-btn-done:hover {
  background: linear-gradient(135deg, rgba(74,158,255,0.32) 0%, rgba(59,130,246,0.22) 100%) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}

/* ─── 72-HOUR HOLD CRISIS BANNERS ────────────────────────────── */
.hold-crisis-banner {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.83rem;
  font-weight: 700;
  margin: 10px 0 4px;
  letter-spacing: 0.3px;
}
.hold-crisis-si {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.40);
  color: #fca5a5;
}
.hold-crisis-hi {
  background: rgba(220,38,38,0.16);
  border: 1px solid rgba(220,38,38,0.55);
  color: #f87171;
}
.hold-crisis-neutral {
  background: rgba(74,158,255,0.08);
  border: 1px solid rgba(74,158,255,0.25);
  color: var(--text-muted);
}

/* ─── 72-HOUR HOLD REPORT CARD ───────────────────────────────── */
.hold-report-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.hold-report-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
}
.hold-report-icon { font-size: 2.2rem; flex-shrink: 0; }
.hold-report-outcome-label {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 2px;
}
.hold-report-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Commit confirm button variant */
.hold-confirm-btn {
  background: linear-gradient(135deg, #dc2626, #991b1b) !important;
  color: #fff !important;
}
.hold-confirm-btn:hover {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  box-shadow: 0 4px 20px rgba(220,38,38,0.45) !important;
}

/* Score board hold entry */
.score-row-hold {
  background: rgba(239,68,68,0.06);
  border-radius: var(--radius-sm);
}
