/* ═══════════════════════════════════════════════════════════════════════
   AKM SOFT CLINIC — Denta-style theme (light + dark)
   ═══════════════════════════════════════════════════════════════════════ */

:root {
  --primary: #5B5BD6;
  --primary-600: #5145CD;
  --primary-light: #EEF0FF;
  --primary-grad: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);

  --bg: #F4F5FB;
  --surface: #FFFFFF;
  --surface-2: #F8F9FD;
  --sidebar-bg: #FFFFFF;
  --border: #ECECF3;
  --border-2: #F1F2F8;

  --text: #1A1A2E;
  --text-soft: #6B7280;
  --text-faint: #9CA3AF;

  --green: #22C55E;
  --green-bg: #E9FBF0;
  --orange: #F59E0B;
  --orange-bg: #FEF5E7;
  --red: #EF4444;
  --red-bg: #FDECEC;
  --blue: #3B82F6;
  --blue-bg: #EAF2FE;
  --purple: #8B5CF6;
  --purple-bg: #F3EEFE;

  --shadow-sm: 0 1px 3px rgba(20,20,50,.05);
  --shadow: 0 4px 20px rgba(20,20,50,.06);
  --shadow-lg: 0 10px 40px rgba(20,20,50,.10);
  --radius: 18px;
  --radius-sm: 12px;
}

html.dark {
  --primary: #7C76FF;
  --primary-600: #6366F1;
  --primary-light: #2A2752;
  --primary-grad: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);

  --bg: #14122B;
  --surface: #1E1B38;
  --surface-2: #252247;
  --sidebar-bg: #1A1733;
  --border: #2E2A50;
  --border-2: #29254A;

  --text: #E8E8F5;
  --text-soft: #A5A3C0;
  --text-faint: #6E6B8F;

  --green-bg: #16331F;
  --orange-bg: #3A2D14;
  --red-bg: #3A1E1E;
  --blue-bg: #16243F;
  --purple-bg: #2A2150;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow: 0 4px 20px rgba(0,0,0,.35);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

body {
  background: var(--bg);
  color: var(--text);
  transition: background .25s, color .25s;
}

/* Scrollbar */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* ── Layout ─────────────────────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
  transition: width .25s, transform .25s;
}
.sidebar.collapsed { width: 76px; }
.main-area { flex: 1; margin-left: 248px; transition: margin .25s; min-width: 0; }
.main-area.expanded { margin-left: 76px; }

/* ── Sidebar brand ──────────────────────────────────────────────────── */
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 22px; margin-bottom: 4px;
}
.brand-logo {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  background: var(--primary-grad);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(99,102,241,.4);
}
.brand-name { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -.5px; }

/* ── Sidebar nav ────────────────────────────────────────────────────── */
.nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 14px; }
.nav-section { font-size: 10px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: .08em; padding: 14px 12px 6px; white-space: nowrap; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; margin-bottom: 2px; border-radius: 12px;
  color: var(--text-soft); font-size: 14px; font-weight: 500;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-grad); color: #fff; box-shadow: 0 6px 16px rgba(99,102,241,.35); }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar.collapsed .nav-label, .sidebar.collapsed .nav-section, .sidebar.collapsed .brand-name { display: none; }

/* Theme toggle pill */
.theme-toggle {
  display: flex; gap: 4px; margin: 14px; padding: 4px;
  background: var(--surface-2); border-radius: 12px;
}
.theme-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; border-radius: 9px; border: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-soft); background: transparent;
}
.theme-btn.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.sidebar.collapsed .theme-btn span { display: none; }

/* ── Topbar ─────────────────────────────────────────────────────────── */
.topbar {
  height: 72px; display: flex; align-items: center; gap: 16px;
  padding: 0 28px; background: transparent;
}
.topbar h1 { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text-soft);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all .15s; position: relative;
}
.icon-btn:hover { color: var(--primary); border-color: var(--primary); }
.icon-btn svg { width: 19px; height: 19px; }

.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 40px; cursor: pointer;
}
.user-chip img, .user-chip .avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 22px; }

/* Stat card */
.stat {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 18px 20px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-sm);
}
.stat-icon { width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-label { font-size: 12px; color: var(--text-soft); font-weight: 500; margin-bottom: 2px; }
.stat-value { font-size: 24px; font-weight: 800; color: var(--text); letter-spacing: -.5px; }

.ic-purple { background: var(--purple-bg); color: var(--purple); }
.ic-blue { background: var(--blue-bg); color: var(--blue); }
.ic-green { background: var(--green-bg); color: var(--green); }
.ic-red { background: var(--red-bg); color: var(--red); }
.ic-orange { background: var(--orange-bg); color: var(--orange); }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 10px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; transition: all .15s; text-decoration: none; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary-grad); color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,.35); }
.btn-primary:hover { opacity: .92; transform: translateY(-1px); }
.btn-soft { background: var(--primary-light); color: var(--primary); }
.btn-soft:hover { background: var(--primary); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--text-soft); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-success { background: linear-gradient(135deg,#22C55E,#16A34A); color: #fff; box-shadow: 0 4px 14px rgba(34,197,94,.3); }
.btn-success:hover { opacity: .92; transform: translateY(-1px); }
.btn-sm { padding: 7px 13px; font-size: 13px; border-radius: 10px; }

/* ── Tabs (pill style like Denta) ───────────────────────────────────── */
.pill-tabs { display: inline-flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; }
.pill-tab { padding: 8px 20px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--text-soft); border: none; background: transparent; cursor: pointer; transition: all .15s; }
.pill-tab.active { background: var(--primary-grad); color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,.3); }

/* Underline tabs */
.u-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.u-tab { padding: 11px 18px; font-size: 14px; font-weight: 600; color: var(--text-soft); border: none; background: none; border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px; }
.u-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Inputs ─────────────────────────────────────────────────────────── */
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="date"], input[type="datetime-local"], input[type="time"], input[type="month"],
input[type="number"], textarea, select {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 11px;
  font-size: 14px; color: var(--text); background: var(--surface); outline: none; font-family: inherit;
  transition: border .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }
textarea { resize: vertical; min-height: 84px; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }
label.fld { display: block; font-size: 12px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }

.search-box { position: relative; }
.search-box svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-faint); pointer-events: none; }
.search-box input { padding-left: 40px; border-radius: 40px; background: var(--surface-2); }

/* ── Badges ─────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 30px; font-size: 12px; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-orange, .badge-yellow { background: var(--orange-bg); color: var(--orange); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-gray { background: var(--surface-2); color: var(--text-soft); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ── Table ──────────────────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th { padding: 14px 18px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-soft); background: var(--surface-2); white-space: nowrap; }
.tbl thead th:first-child { border-top-left-radius: 12px; border-bottom-left-radius: 12px; }
.tbl thead th:last-child { border-top-right-radius: 12px; border-bottom-right-radius: 12px; }
.tbl tbody td { padding: 14px 18px; font-size: 14px; color: var(--text); border-bottom: 1px solid var(--border-2); }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }

.avatar {
  border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; background: var(--primary-grad); flex-shrink: 0;
}

/* Row action icon buttons */
.row-act { width: 32px; height: 32px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; transition: all .12s; }
.row-act svg { width: 16px; height: 16px; }
.ra-view { background: var(--blue-bg); color: var(--blue); }
.ra-edit { background: var(--purple-bg); color: var(--purple); }
.ra-del  { background: var(--red-bg); color: var(--red); }
.ra-view:hover, .ra-edit:hover, .ra-del:hover { transform: scale(1.08); }

/* ── Modal ──────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,15,40,.55); backdrop-filter: blur(4px); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: var(--surface); border-radius: 22px; box-shadow: var(--shadow-lg); width: 100%; max-height: 90vh; overflow-y: auto; animation: modalIn .2s ease; }
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(-8px); } to { opacity: 1; transform: scale(1); } }

/* Dropdown */
.dropdown { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; min-width: 180px; animation: modalIn .12s ease; }
.dropdown a, .dropdown button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 9px; font-size: 14px; color: var(--text); text-decoration: none; border: none; background: none; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); }
.dropdown svg { width: 16px; height: 16px; color: var(--text-soft); }

/* Progress bar */
.progress { height: 8px; background: var(--surface-2); border-radius: 30px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary-grad); border-radius: 30px; }

/* Utilities */
.muted { color: var(--text-soft); }
.faint { color: var(--text-faint); }
.divider { height: 1px; background: var(--border); }
hr { border: none; border-top: 1px solid var(--border); }

/* Page fade */
.page-fade { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

/* Checkbox tags */
.tags-group ul { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.tags-group label { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 30px; border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; color: var(--text-soft); cursor: pointer; }
.tags-group input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--primary); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

/* Toast */
.toast-enter { animation: toastIn .3s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateX(100%); } to { opacity: 1; } }

/* ═══ Dark-mode overrides for legacy Tailwind utility classes ═══════════ */
html.dark .bg-white { background: var(--surface) !important; }
html.dark .bg-slate-50, html.dark .bg-slate-100, html.dark .bg-gray-50, html.dark .bg-gray-100 { background: var(--surface-2) !important; }
html.dark .text-slate-900, html.dark .text-slate-800, html.dark .text-gray-900, html.dark .text-gray-800 { color: var(--text) !important; }
html.dark .text-slate-700, html.dark .text-slate-600, html.dark .text-slate-500, html.dark .text-gray-700, html.dark .text-gray-600, html.dark .text-gray-500 { color: var(--text-soft) !important; }
html.dark .text-slate-400, html.dark .text-slate-300, html.dark .text-gray-400 { color: var(--text-faint) !important; }
html.dark .border-slate-100, html.dark .border-slate-200, html.dark .border-gray-100, html.dark .border-gray-200, html.dark .border-slate-50 { border-color: var(--border) !important; }
html.dark .divide-slate-50 > :not([hidden]) ~ :not([hidden]), html.dark .divide-slate-100 > :not([hidden]) ~ :not([hidden]) { border-color: var(--border) !important; }
html.dark .hover\:bg-slate-50:hover, html.dark .hover\:bg-slate-100:hover { background: var(--surface-2) !important; }
html.dark .shadow-sm, html.dark .shadow, html.dark .shadow-lg, html.dark .shadow-xl { box-shadow: var(--shadow) !important; }

/* ── Tom Select (searchable dropdowns) ─────────────────────────────────── */
.ts-wrapper { width: 100%; }
.ts-control {
  background: var(--surface) !important; border: 1px solid var(--border) !important;
  border-radius: 11px !important; padding: 8px 12px !important; min-height: 42px;
  color: var(--text) !important; box-shadow: none !important;
}
.ts-control input { color: var(--text) !important; }
.ts-wrapper.focus .ts-control { border-color: var(--primary) !important; box-shadow: 0 0 0 3px rgba(99,102,241,.12) !important; }
.ts-dropdown {
  background: var(--surface) !important; border: 1px solid var(--border) !important;
  border-radius: 12px !important; box-shadow: var(--shadow-lg) !important; margin-top: 4px; overflow: hidden;
}
.ts-dropdown .option { color: var(--text) !important; padding: 9px 13px !important; }
.ts-dropdown .option.active { background: var(--primary-light) !important; color: var(--primary) !important; }
.ts-dropdown .optgroup-header { color: var(--text-faint) !important; font-size: 11px; font-weight: 700; text-transform: uppercase; background: var(--surface-2) !important; }
.ts-control .item { color: var(--text) !important; }
.ts-wrapper.single .ts-control:after { border-color: var(--text-faint) transparent transparent !important; }

/* ═══ Back-compat aliases (legacy templates) ═══════════════════════════ */
.btn-primary, .btn-ghost, .btn-success {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  padding: 10px 18px; border-radius: 12px; font-size: 14px; font-weight: 600;
  border: none; cursor: pointer; transition: all .15s; text-decoration: none; white-space: nowrap;
}
.btn-primary svg, .btn-ghost svg, .btn-success svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary-grad); color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,.35); }
.btn-primary:hover { opacity: .92; transform: translateY(-1px); }
.btn-ghost { background: var(--surface); color: var(--text-soft); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-success { background: linear-gradient(135deg,#22C55E,#16A34A); color: #fff; box-shadow: 0 4px 14px rgba(34,197,94,.3); }
.btn-success:hover { opacity: .92; transform: translateY(-1px); }

/* legacy data-table → tbl */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead tr { background: var(--surface-2); }
.data-table th { padding: 13px 18px; text-align: left; font-size: 12px; font-weight: 600; color: var(--text-soft); text-transform: none; }
.data-table td { padding: 14px 18px; font-size: 14px; color: var(--text); border-top: 1px solid var(--border-2); }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:first-child td { border-top: none; }

/* legacy tab-btn */
.tab-btn { padding: 10px 18px; font-size: 14px; font-weight: 600; color: var(--text-soft); border: none; background: none; border-bottom: 2px solid transparent; cursor: pointer; }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover:not(.active) { color: var(--text); }

/* legacy form inputs */
.form-input, .form-select { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 11px; font-size: 14px; color: var(--text); background: var(--surface); outline: none; }
.form-input:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

/* legacy gradient stat cards */
.card-gradient { border-radius: var(--radius); color: #fff; padding: 20px; box-shadow: var(--shadow); }
.stat-indigo { background: linear-gradient(135deg,#6366F1,#8B5CF6); }
.stat-emerald { background: linear-gradient(135deg,#22C55E,#16A34A); }
.stat-amber { background: linear-gradient(135deg,#F59E0B,#D97706); }
.stat-rose { background: linear-gradient(135deg,#F43F5E,#DC2626); }
.stat-sky { background: linear-gradient(135deg,#0EA5E9,#2563EB); }
.stat-purple { background: linear-gradient(135deg,#A855F7,#7C3AED); }

/* legacy modal helpers already defined above; tags-group above */
