/* ═══════════════════════════════════════════════════════════
   SELINA — Design System
   Palette: deep violet #1E0B38, soft lavender #7C3AED,
            bright aqua #06B6D4, warm rose #F43F5E,
            clean white #FFFFFF, slate #F8FAFC
   Type: DM Sans (UI) + DM Serif Display (brand moments)
═══════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Serif+Display:ital@0;1&display=swap');

:root {
  --violet:   #1E0B38;
  --violet2:  #2D1154;
  --purple:   #7C3AED;
  --purple-l: #9F67FF;
  --aqua:     #06B6D4;
  --aqua-l:   #22D3EE;
  --rose:     #F43F5E;
  --slate:    #F8FAFC;
  --slate2:   #F1F5F9;
  --border:   #E2E8F0;
  --muted:    #64748B;
  --text:     #1E293B;
  --white:    #FFFFFF;
  --success:  #10B981;
  --warning:  #F59E0B;
  --danger:   #EF4444;
  --r:        12px;
  --r-lg:     20px;
  --shadow:   0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:0 8px 32px rgba(0,0,0,.12);
  --t:        0.22s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body { font-family: 'DM Sans', sans-serif; color: var(--text); background: var(--slate); line-height: 1.6; }
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }

/* ── TYPOGRAPHY ── */
.serif { font-family: 'DM Serif Display', serif; }
h1 { font-size: clamp(1.8rem,3.5vw,2.8rem); font-weight: 700; line-height: 1.15; color: var(--text); }
h2 { font-size: clamp(1.4rem,2.5vw,2rem);   font-weight: 700; line-height: 1.2;  color: var(--text); }
h3 { font-size: 1.1rem; font-weight: 600; line-height: 1.3; color: var(--text); }
h4 { font-size: 0.95rem; font-weight: 600; color: var(--text); }
p  { color: var(--muted); line-height: 1.7; }
small { font-size: 0.8rem; }

/* ── LAYOUT ── */
.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 800px; margin: 0 auto; padding: 0 24px; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 22px; border-radius: 8px; border: none;
  font-size: 0.9rem; font-weight: 600; line-height: 1;
  transition: var(--t); cursor: pointer; white-space: nowrap;
  font-family: 'DM Sans', sans-serif;
}
.btn-sm  { padding: 7px 14px; font-size: 0.8rem; }
.btn-lg  { padding: 13px 28px; font-size: 1rem; }
.btn-primary   { background: var(--purple); color: var(--white); }
.btn-primary:hover { background: var(--purple-l); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(124,58,237,.3); }
.btn-aqua      { background: var(--aqua); color: var(--white); }
.btn-aqua:hover{ background: var(--aqua-l); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(6,182,212,.3); }
.btn-outline   { background: transparent; color: var(--purple); border: 1.5px solid var(--purple); }
.btn-outline:hover { background: rgba(124,58,237,.06); }
.btn-ghost     { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--slate2); color: var(--text); }
.btn-danger    { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #DC2626; }
.btn-success   { background: var(--success); color: var(--white); }
.btn:disabled  { opacity: .5; pointer-events: none; }

/* ── BADGES ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 100px;
  font-size: 0.72rem; font-weight: 600; letter-spacing: .02em;
}
.badge::before { content:''; width:6px; height:6px; border-radius:50%; background:currentColor; opacity:.6; }
.badge-success { background: rgba(16,185,129,.1); color: #059669; }
.badge-warning { background: rgba(245,158,11,.1); color: #D97706; }
.badge-danger  { background: rgba(239,68,68,.1);  color: #DC2626; }
.badge-info    { background: rgba(6,182,212,.1);  color: #0891B2; }
.badge-purple  { background: rgba(124,58,237,.1); color: var(--purple); }

/* ── CARDS ── */
.card {
  background: var(--white); border-radius: var(--r-lg);
  border: 1px solid var(--border); padding: 24px;
  box-shadow: var(--shadow);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.card-title  { font-size: 1rem; font-weight: 600; color: var(--text); }

/* ── FORMS ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-label .req { color: var(--rose); margin-left: 2px; }
.form-control {
  width: 100%; padding: 10px 14px; border-radius: 8px;
  border: 1.5px solid var(--border); font-size: 0.9rem; color: var(--text);
  background: var(--white); transition: var(--t);
  font-family: 'DM Sans', sans-serif;
}
.form-control:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(124,58,237,.12); }
.form-control::placeholder { color: #A0AEC0; }
.form-control.error { border-color: var(--danger); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-hint { font-size: 0.78rem; color: var(--muted); margin-top: 5px; }
.form-error { font-size: 0.78rem; color: var(--danger); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── TABLES ── */
.table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
thead th { background: var(--slate); padding: 12px 16px; text-align: left; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 14px 16px; border-bottom: 1px solid var(--slate2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--slate); }

/* ── ALERTS ── */
.alert { padding: 13px 16px; border-radius: 8px; font-size: 0.88rem; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.alert-success { background: rgba(16,185,129,.08); color: #065F46; border: 1px solid rgba(16,185,129,.2); }
.alert-danger  { background: rgba(239,68,68,.08);  color: #991B1B; border: 1px solid rgba(239,68,68,.2); }
.alert-info    { background: rgba(6,182,212,.08);  color: #164E63; border: 1px solid rgba(6,182,212,.2); }
.alert-warning { background: rgba(245,158,11,.08); color: #78350F; border: 1px solid rgba(245,158,11,.2); }

/* ── SIDEBAR LAYOUT ── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; flex-shrink: 0;
  background: var(--violet);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 50; overflow-y: auto;
  transition: var(--t);
}
.sidebar-logo {
  padding: 24px 20px 20px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--purple), var(--aqua));
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-logo-mark svg { width: 18px; height: 18px; fill: white; }
.sidebar-logo-text { font-family: 'DM Serif Display', serif; font-size: 1.4rem; color: var(--white); letter-spacing: .01em; }
.sidebar-logo-sub  { font-size: 0.65rem; color: rgba(255,255,255,.4); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; margin-top: 1px; }
.sidebar-section { padding: 20px 12px 8px; }
.sidebar-section-label { font-size: 0.65rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: rgba(255,255,255,.3); padding: 0 8px; margin-bottom: 6px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 2px;
  font-size: 0.88rem; font-weight: 500; color: rgba(255,255,255,.6);
  transition: var(--t);
}
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-link:hover { background: rgba(255,255,255,.07); color: var(--white); }
.sidebar-link.active { background: rgba(124,58,237,.4); color: var(--white); }
.sidebar-link .badge { margin-left: auto; }
.sidebar-footer {
  margin-top: auto; padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; cursor: pointer; transition: var(--t); }
.sidebar-user:hover { background: rgba(255,255,255,.07); }
.sidebar-avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg,var(--purple),var(--aqua)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; color: white; flex-shrink: 0; }
.sidebar-user-name { font-size: 0.85rem; font-weight: 600; color: var(--white); }
.sidebar-user-role { font-size: 0.72rem; color: rgba(255,255,255,.4); }

/* ── TOPBAR ── */
.topbar {
  height: 64px; background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--white); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: var(--t); color: var(--muted); position: relative;
}
.icon-btn:hover { background: var(--slate); color: var(--text); }
.notif-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--rose); border: 2px solid var(--white); }

/* ── MAIN CONTENT ── */
.main-content { margin-left: 260px; flex: 1; min-height: 100vh; display: flex; flex-direction: column; }
.page-body { flex: 1; padding: 28px; }

/* ── STAT CARDS ── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { background: var(--white); border-radius: var(--r-lg); border: 1px solid var(--border); padding: 20px 22px; box-shadow: var(--shadow); }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; margin-bottom: 14px; }
.stat-icon-purple { background: rgba(124,58,237,.1); }
.stat-icon-aqua   { background: rgba(6,182,212,.1); }
.stat-icon-rose   { background: rgba(244,63,94,.1); }
.stat-icon-green  { background: rgba(16,185,129,.1); }
.stat-num  { font-size: 1.8rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label{ font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.stat-delta{ font-size: 0.75rem; margin-top: 8px; font-weight: 600; }
.stat-delta.up   { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ── STEP WIZARD (Patient Intake) ── */
.wizard-steps { display: flex; align-items: center; margin-bottom: 36px; }
.wizard-step { display: flex; align-items: center; gap: 10px; flex: 1; }
.wizard-step:last-child { flex: 0; }
.wizard-step-num { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 0.82rem; font-weight: 700; color: var(--muted); flex-shrink: 0; transition: var(--t); }
.wizard-step.active .wizard-step-num   { border-color: var(--purple); background: var(--purple); color: white; }
.wizard-step.done   .wizard-step-num   { border-color: var(--success); background: var(--success); color: white; }
.wizard-step-label { font-size: 0.8rem; font-weight: 500; color: var(--muted); transition: var(--t); white-space: nowrap; }
.wizard-step.active .wizard-step-label { color: var(--purple); font-weight: 600; }
.wizard-step.done   .wizard-step-label { color: var(--success); }
.wizard-connector { flex: 1; height: 2px; background: var(--border); margin: 0 12px; transition: var(--t); }
.wizard-connector.done { background: var(--success); }

/* ── MODAL ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; opacity: 0; pointer-events: none; transition: var(--t); }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--white); border-radius: var(--r-lg); padding: 32px; max-width: 540px; width: 100%; box-shadow: var(--shadow-lg); transform: translateY(16px) scale(.97); transition: var(--t); }
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--slate); color: var(--text); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ── TABS ── */
.tabs { display: flex; gap: 4px; background: var(--slate2); border-radius: 10px; padding: 4px; margin-bottom: 24px; }
.tab { flex: 1; padding: 8px 16px; border-radius: 7px; border: none; background: transparent; font-size: 0.85rem; font-weight: 600; color: var(--muted); cursor: pointer; transition: var(--t); font-family: 'DM Sans', sans-serif; }
.tab.active { background: var(--white); color: var(--text); box-shadow: var(--shadow); }

/* ── CHAT / MESSAGING ── */
.chat-layout { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - 120px); gap: 0; background: var(--white); border-radius: var(--r-lg); border: 1px solid var(--border); overflow: hidden; }
.chat-list { border-right: 1px solid var(--border); overflow-y: auto; }
.chat-list-header { padding: 16px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 0.95rem; }
.chat-item { padding: 14px 16px; cursor: pointer; transition: var(--t); border-bottom: 1px solid var(--slate2); display: flex; align-items: center; gap: 12px; }
.chat-item:hover { background: var(--slate); }
.chat-item.active { background: rgba(124,58,237,.06); border-left: 3px solid var(--purple); }
.chat-item-avatar { width: 40px; height: 40px; border-radius: 50%; background: linear-gradient(135deg,var(--purple),var(--aqua)); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; color: white; flex-shrink: 0; }
.chat-item-name { font-weight: 600; font-size: 0.88rem; color: var(--text); }
.chat-item-preview { font-size: 0.78rem; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-time { font-size: 0.72rem; color: var(--muted); margin-left: auto; flex-shrink: 0; }
.chat-unread { width: 18px; height: 18px; border-radius: 50%; background: var(--purple); color: white; font-size: 0.65rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.chat-window { display: flex; flex-direction: column; }
.chat-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; background: var(--slate); }
.message { max-width: 68%; }
.message.mine { align-self: flex-end; }
.message.theirs { align-self: flex-start; }
.message-bubble { padding: 11px 15px; border-radius: 16px; font-size: 0.88rem; line-height: 1.5; }
.message.mine   .message-bubble { background: var(--purple); color: white; border-bottom-right-radius: 4px; }
.message.theirs .message-bubble { background: var(--white); color: var(--text); border-bottom-left-radius: 4px; box-shadow: var(--shadow); }
.message-time { font-size: 0.7rem; color: var(--muted); margin-top: 4px; }
.message.mine .message-time { text-align: right; }
.chat-input-area { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-end; }
.chat-input { flex: 1; border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 14px; font-size: 0.9rem; font-family: 'DM Sans', sans-serif; resize: none; max-height: 120px; transition: var(--t); }
.chat-input:focus { outline: none; border-color: var(--purple); box-shadow: 0 0 0 3px rgba(124,58,237,.1); }

/* ── CALENDAR SLOTS ── */
.time-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.time-slot { padding: 10px 8px; text-align: center; border-radius: 8px; border: 1.5px solid var(--border); font-size: 0.82rem; font-weight: 600; cursor: pointer; transition: var(--t); color: var(--text); }
.time-slot:hover:not(.taken)   { border-color: var(--purple); color: var(--purple); background: rgba(124,58,237,.05); }
.time-slot.selected { border-color: var(--purple); background: var(--purple); color: white; }
.time-slot.taken    { background: var(--slate2); color: var(--muted); cursor: not-allowed; text-decoration: line-through; }

/* ── PROGRESS BARS ── */
.progress { height: 6px; background: var(--slate2); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--purple), var(--aqua)); transition: width .6s ease; }

/* ── RATING STARS ── */
.stars { display: flex; gap: 4px; }
.star { font-size: 1.2rem; cursor: pointer; color: var(--border); transition: var(--t); }
.star.lit, .star:hover { color: var(--warning); }

/* ── TOAST ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--text); color: white; padding: 13px 18px; border-radius: 10px; font-size: 0.88rem; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; min-width: 260px; animation: slideIn .25s ease; }
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }

/* ── UTILITIES ── */
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.gap-4       { gap: 16px; }
.mt-1        { margin-top: 4px; }
.mt-2        { margin-top: 8px; }
.mt-3        { margin-top: 12px; }
.mt-4        { margin-top: 16px; }
.mb-4        { margin-bottom: 16px; }
.mb-6        { margin-bottom: 24px; }
.text-muted  { color: var(--muted); }
.text-sm     { font-size: 0.82rem; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.font-bold   { font-weight: 700; }
.hidden      { display: none !important; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider     { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ── RESPONSIVE ── */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .sidebar   { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}
@media (max-width: 640px) {
  .stat-grid    { grid-template-columns: 1fr; }
  .form-row     { grid-template-columns: 1fr; }
  .form-row-3   { grid-template-columns: 1fr; }
  .time-slots   { grid-template-columns: repeat(3, 1fr); }
  .chat-layout  { grid-template-columns: 1fr; }
  .page-body    { padding: 16px; }
}
