/* ============================================================
   SAPPHIRE ROOTS CLINIC CMS — DESIGN SYSTEM
   clinic.sapphireroots.com
   ============================================================ */

:root {
  --primary: #0D9488;
  --primary-dark: #134E4A;
  --primary-light: #CCFBF1;
  --gold: #C9A84C;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #14B8A6;
  --dark: #0F172A;
  --sidebar-bg: #0F172A;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --white: #FFFFFF;
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1E293B;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.5;
}

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

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--transition);
}
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #14B8A6);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.sidebar-brand-name {
  font-size: 13px; font-weight: 700;
  color: #fff; line-height: 1.2;
  letter-spacing: 0.01em;
}
.sidebar-brand-sub {
  font-size: 10px; color: rgba(255,255,255,0.35);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section-label {
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: 16px 20px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  text-decoration: none;
  color: rgba(255,255,255,0.55);
  font-size: 13.5px; font-weight: 500;
  border-radius: 0;
  transition: all var(--transition);
  position: relative;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.07); }
.nav-item.active {
  color: #fff;
  background: rgba(13,148,136,0.35);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg { opacity: 1; }
.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 18px; text-align: center;
}
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-sm);
}
.sidebar-user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--gold));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-user-name { font-size: 12.5px; font-weight: 600; color: #fff; }
.sidebar-user-role { font-size: 10px; color: rgba(255,255,255,0.35); text-transform: capitalize; }

/* TOPBAR */
.topbar {
  position: fixed;
  top: 0; left: var(--sidebar-width); right: 0;
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center;
  padding: 0 28px;
  z-index: 90;
  gap: 16px;
}
.topbar-title {
  font-size: 17px; font-weight: 700;
  color: var(--dark);
  flex: 1;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  color: var(--gray-600);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}
.topbar-btn:hover { border-color: var(--primary); color: var(--primary); }
.topbar-btn.primary {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
}
.topbar-btn.primary:hover { background: var(--primary-dark); }

/* MAIN CONTENT */
.main {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 28px;
  min-height: calc(100vh - var(--topbar-height));
}

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 15px; font-weight: 700;
  color: var(--dark);
}
.card-body { padding: 24px; }
.card-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* STAT CARDS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  min-width: 0;
}
.stat-card > *:not(.stat-icon) {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-light); }
.stat-icon.green { background: #D1FAE5; }
.stat-icon.gold { background: #FEF3C7; }
.stat-icon.red { background: #FEE2E2; }
.stat-icon.purple { background: #EDE9FE; }
.stat-value {
  font-size: 20px; font-weight: 700;
  color: var(--dark); line-height: 1.2;
  margin-bottom: 4px;
  word-break: keep-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  letter-spacing: -0.02em;
}
/* Currency cards: even smaller because rupee values are long */
.stat-card.currency .stat-value,
.stat-value.currency {
  font-size: 17px;
  font-weight: 700;
}
@media (max-width: 1100px) {
  .stat-value { font-size: 18px; }
  .stat-card.currency .stat-value, .stat-value.currency { font-size: 15px; }
}
.stat-label { font-size: 12px; color: var(--gray-500); font-weight: 500; line-height: 1.4; }
.stat-change {
  font-size: 11px; margin-top: 4px;
  display: flex; align-items: center; gap: 3px;
}
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody td {
  padding: 13px 16px;
  font-size: 13.5px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
.td-primary { font-weight: 600; color: var(--dark); }
.td-muted { color: var(--gray-400); font-size: 12px; }

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.badge-blue    { background: var(--primary-light); color: var(--primary); }
.badge-green   { background: #D1FAE5; color: #065F46; }
.badge-yellow  { background: #FEF3C7; color: #92400E; }
.badge-red     { background: #FEE2E2; color: #991B1B; }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }
.badge-purple  { background: #EDE9FE; color: #5B21B6; }

/* Status → colour mapping */
.status-scheduled    { @extend .badge-blue; }
.status-confirmed    { @extend .badge-green; }
.status-completed    { @extend .badge-green; }
.status-cancelled    { @extend .badge-red; }
.status-no_show      { @extend .badge-yellow; }
.status-pending      { @extend .badge-yellow; }
.status-paid         { @extend .badge-green; }
.status-partial      { @extend .badge-yellow; }
.status-new          { @extend .badge-blue; }
.status-converted    { @extend .badge-green; }
.status-lost         { @extend .badge-red; }

/* ============================================================
   FORMS
   ============================================================ */
.form-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 18px; }
.form-grid.cols-3 { grid-template-columns: repeat(3,1fr); }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label {
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--gray-500);
}
input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--dark);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,148,136,0.1);
}
textarea { min-height: 90px; resize: vertical; }
.form-hint { font-size: 11px; color: var(--gray-400); margin-top: 3px; }
.form-error { font-size: 11px; color: var(--danger); margin-top: 3px; }
.input-group { position: relative; }
.input-group input { padding-left: 38px; }
.input-group-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}
.input-prefix {
  position: absolute; left: 0; top: 0; bottom: 0;
  display: flex; align-items: center;
  padding: 0 12px;
  font-size: 14px; font-weight: 600;
  color: var(--gray-500);
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.input-with-prefix input { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font-size: 13.5px; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-outline { background: transparent; color: var(--gray-600); border-color: var(--gray-300); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--gray-600); border-color: transparent; }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; border-radius: var(--radius-xs); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   ALERTS & TOASTS
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 16px;
  border-left: 4px solid;
}
.alert-success { background: #D1FAE5; border-color: var(--success); color: #065F46; }
.alert-danger   { background: #FEE2E2; border-color: var(--danger);  color: #991B1B; }
.alert-warning  { background: #FEF3C7; border-color: var(--warning); color: #92400E; }
.alert-info     { background: var(--primary-light); border-color: var(--primary); color: var(--primary-dark); }
.toast-container {
  position: fixed; top: 80px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  display: flex; align-items: center; gap: 10px;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; visibility: hidden;
  transition: all var(--transition);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--dark); }
.modal-close {
  width: 30px; height: 30px;
  border-radius: var(--radius-xs);
  background: var(--gray-100);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-500);
  font-size: 16px;
}
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex; justify-content: flex-end; gap: 10px;
}
.modal-lg { max-width: 900px; }
.modal-xl { max-width: 1100px; }

/* ============================================================
   FILTERS & SEARCH
   ============================================================ */
.filter-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  flex-wrap: wrap;
}
.search-box { position: relative; }
.search-box input { padding-left: 36px; min-width: 240px; }
.search-box svg {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400); width: 16px; height: 16px;
}
.filter-bar select { min-width: 140px; }
.filter-bar .ms-auto { margin-left: auto; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex; align-items: center; gap: 4px;
  padding: 14px 20px;
  border-top: 1px solid var(--gray-200);
}
.page-item {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-xs);
  border: 1.5px solid var(--gray-200);
  font-size: 13px; font-weight: 500;
  color: var(--gray-600);
  text-decoration: none; cursor: pointer;
  transition: all var(--transition);
}
.page-item:hover { border-color: var(--primary); color: var(--primary); }
.page-item.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-item.disabled { opacity: 0.4; cursor: default; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 16px; color: var(--gray-600); margin-bottom: 8px; }
.empty-state p { font-size: 13px; margin-bottom: 20px; }

/* ============================================================
   UTILITIES
   ============================================================ */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--gray-400); }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.hidden { display: none; }
.rupee { font-family: monospace; }
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

/* WhatsApp action button */
.btn-whatsapp {
  background: #25D366; color: #fff; border-color: #25D366;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-whatsapp:hover { background: #1DA851; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar { left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 640px) {
  .main { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr; }
  .card-body { padding: 16px; }
  .filter-bar { flex-direction: column; align-items: stretch; }
}


/* ──────────────────────────────────────────────
   Collapsible Sidebar Groups
   ────────────────────────────────────────────── */
.nav-group {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.nav-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 11px 16px;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: color 0.15s, background 0.15s;
    text-align: left;
    font-family: inherit;
}
.nav-group-header:hover {
    color: white;
    background: rgba(255, 255, 255, 0.06);
}
.nav-group-icon {
    font-size: 14px;
    flex-shrink: 0;
}
.nav-group-label {
    flex: 1;
    text-align: left;
}
.nav-group-chevron {
    font-size: 16px;
    transition: transform 0.2s ease;
    display: inline-block;
    transform: rotate(0deg);
    opacity: 0.5;
}
.nav-group.open > .nav-group-header .nav-group-chevron {
    transform: rotate(90deg);
    opacity: 1;
}
.nav-group.open > .nav-group-header {
    color: rgba(255, 255, 255, 0.9);
}
.nav-group-items {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease-out;
}
.nav-group.open > .nav-group-items {
    max-height: 600px;
}
.nav-group .nav-item {
    padding: 9px 16px 9px 42px;
    font-size: 13px;
}
.nav-item-icon {
    margin-right: 6px;
    font-size: 13px;
}