/* --- PhysioDesk - Master Stylesheet --------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --sidebar: #0f2744;
  --sidebar-hover: rgba(255,255,255,.07);
  --sidebar-active: #3b82f6;
  --bg: #f0f4f8;
  --white: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #1e293b;
  --text-2: #475569;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --accent-dark: #1d4ed8;
  --accent-light: #eff6ff;
  --green: #10b981;
  --green-light: #ecfdf5;
  --red: #ef4444;
  --red-light: #fef2f2;
  --amber: #f59e0b;
  --amber-light: #fffbeb;
  --purple: #8b5cf6;
  --purple-light: #f5f3ff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 20px 40px rgba(0,0,0,.12);
  --font: 'Inter', system-ui, sans-serif;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.5; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

/* --- LAYOUT --- */
.app-wrapper { display: block; min-height: 100vh; overflow: visible; }
.sidebar { width: 230px; background: var(--sidebar); display: flex; flex-direction: column; flex-shrink: 0; height: 100vh; overflow-y: auto; }
.main { display: flex; flex-direction: column; min-height: 100vh; overflow: visible; }
.content { flex: 1; overflow: visible; padding: 24px; min-height: calc(100vh - 56px); }

/* --- SIDEBAR --- */
.logo { padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.logo-icon { font-size: 22px; color: var(--accent); }
.logo-name { font-size: 17px; font-weight: 700; color: #fff; margin-top: 4px; }
.logo-sub { font-size: 11px; color: #64748b; }

.nav-section { padding: 12px 0 4px; }
.nav-label { font-size: 10px; font-weight: 600; color: #475569; text-transform: uppercase; letter-spacing: .08em; padding: 0 18px; margin-bottom: 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 18px; color: #94a3b8; font-size: 13px; cursor: pointer; transition: all .15s; position: relative; border-left: 3px solid transparent; }
.nav-link:hover { color: #e2e8f0; background: var(--sidebar-hover); }
.nav-link.active { color: #fff; background: rgba(59,130,246,.15); border-left-color: var(--accent); }
.nav-link i { font-size: 18px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 10px; border-radius: 10px; padding: 1px 7px; font-weight: 600; }

.sidebar-bottom { margin-top: auto; padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #e2e8f0; }
.user-role { font-size: 11px; color: #64748b; }

/* --- TOPBAR --- */
.topbar { background: var(--white); border-bottom: 1px solid var(--border); padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.search-wrap { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 14px; width: 240px; transition: border .15s; }
.search-wrap:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.search-wrap input { border: none; background: transparent; outline: none; font-size: 13px; color: var(--text); width: 100%; font-family: var(--font); }
.topbar-icon { position: relative; cursor: pointer; color: var(--muted); font-size: 20px; padding: 6px; border-radius: 6px; transition: background .15s; }
.topbar-icon:hover { background: var(--bg); color: var(--text); }
.notif-dot { width: 8px; height: 8px; background: var(--red); border-radius: 50%; position: absolute; top: 4px; right: 4px; border: 2px solid #fff; }

/* --- CARDS --- */
.card { background: var(--white); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.card-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }

/* --- STAT CARDS --- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.stat-card.blue::before { background: var(--accent); }
.stat-card.green::before { background: var(--green); }
.stat-card.amber::before { background: var(--amber); }
.stat-card.red::before { background: var(--red); }
.stat-card.purple::before { background: var(--purple); }
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 12px; }
.ic-blue { background: var(--accent-light); color: var(--accent); }
.ic-green { background: var(--green-light); color: var(--green); }
.ic-amber { background: var(--amber-light); color: var(--amber); }
.ic-red { background: var(--red-light); color: var(--red); }
.ic-purple { background: var(--purple-light); color: var(--purple); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-sub { font-size: 12px; margin-top: 6px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.trend-up { color: var(--green); }
.trend-down { color: var(--red); }

/* --- TABLES --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 16px; text-align: left; background: #f8fafc; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 12px 16px; font-size: 13px; vertical-align: middle; }
.td-bold { font-weight: 600; }
.td-accent { color: var(--accent); font-weight: 600; }

/* --- BADGES --- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.b-green { background: var(--green-light); color: #059669; }
.b-red { background: var(--red-light); color: #dc2626; }
.b-amber { background: var(--amber-light); color: #d97706; }
.b-blue { background: var(--accent-light); color: var(--accent-dark); }
.b-purple { background: var(--purple-light); color: #7c3aed; }
.b-gray { background: #f1f5f9; color: #475569; }

/* --- BUTTONS --- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all .15s; font-family: var(--font); white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-outline { background: var(--white); color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); border-color: var(--border-strong); }
.btn-success { background: var(--green-light); color: #065f46; border: 1px solid #a7f3d0; }
.btn-danger { background: var(--red-light); color: var(--red); border: 1px solid #fecaca; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-icon { padding: 7px; border-radius: 6px; }

/* --- FORMS --- */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
label.form-label { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.form-control { border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 13px; font-size: 13px; outline: none; background: var(--white); color: var(--text); width: 100%; transition: border .15s, box-shadow .15s; font-family: var(--font); }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.form-control:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
.section-divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.section-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 14px; }

/* --- PROGRESS --- */
.progress-track { background: #e2e8f0; border-radius: 4px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; transition: width .4s ease; }

/* --- MODALS --- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,39,68,.5); z-index: 1000; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(2px); }
.modal-overlay.open { display: flex; }
.modal { background: var(--white); border-radius: 16px; width: 100%; max-width: 580px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: modalIn .2s ease; }
.modal-lg { max-width: 700px; }
@keyframes modalIn { from { opacity: 0; transform: scale(.96) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--white); z-index: 1; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--white); }
.close-btn { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 24px; line-height: 1; padding: 0; border-radius: 6px; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; transition: all .15s; }
.close-btn:hover { background: var(--bg); color: var(--text); }

/* --- TABS --- */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; gap: 0; }
.tab-item { padding: 9px 18px; font-size: 13px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab-item:hover:not(.active) { color: var(--text); }
.tab-item.active { color: var(--accent); border-bottom-color: var(--accent); }

/* --- SCHEDULE SLOTS --- */
.slot-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.slot-row:last-child { border-bottom: none; }
.slot-time { width: 64px; font-size: 12px; color: var(--muted); font-weight: 600; flex-shrink: 0; }
.slot-card { flex: 1; padding: 8px 12px; border-radius: var(--radius); font-size: 13px; border-left: 3px solid; }
.slot-blue { background: var(--accent-light); border-color: var(--accent); color: #1e3a5f; }
.slot-green { background: var(--green-light); border-color: var(--green); color: #064e3b; }
.slot-purple { background: var(--purple-light); border-color: var(--purple); color: #3b0764; }
.slot-amber { background: var(--amber-light); border-color: var(--amber); color: #451a03; }
.slot-empty { background: #f8fafc; border: 1px dashed var(--border); text-align: center; color: var(--muted); font-size: 12px; border-left: none; }
.slot-name { font-weight: 600; font-size: 12px; }
.slot-meta { font-size: 11px; opacity: .8; margin-top: 2px; }

/* --- TREATMENT ITEMS --- */
.t-item { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.t-item:last-child { border-bottom: none; }
.t-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.t-dot-done { background: var(--green); }
.t-dot-progress { background: var(--amber); }
.t-dot-pending { background: #e2e8f0; }

/* --- CALENDAR --- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-dhead { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 4px 2px; }
.cal-day { padding: 7px 2px; border-radius: 6px; font-size: 12px; cursor: pointer; position: relative; transition: background .1s; }
.cal-day:hover { background: var(--bg); }
.cal-day.today { background: var(--accent); color: #fff; font-weight: 700; }
.cal-day.other { color: #cbd5e1; }
.cal-day .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--green); position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); }
.cal-day.today .dot { background: rgba(255,255,255,.7); }

/* --- VITALS BARS --- */
.vbar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.vbar-label { width: 110px; font-size: 11px; color: var(--muted); text-align: right; flex-shrink: 0; }
.vbar-track { flex: 1; background: #e2e8f0; border-radius: 4px; height: 8px; overflow: hidden; }
.vbar-fill { height: 100%; border-radius: 4px; transition: width .4s; }
.vbar-val { width: 44px; font-size: 12px; font-weight: 600; }

/* --- RECEIPT --- */
.receipt-box { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 28px; max-width: 440px; margin: 0 auto; }
.receipt-logo { text-align: center; border-bottom: 1px dashed var(--border); padding-bottom: 16px; margin-bottom: 16px; }
.receipt-co { font-size: 20px; font-weight: 700; color: var(--accent); }
.receipt-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.inv-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.inv-total { display: flex; justify-content: space-between; padding: 12px 0; font-size: 15px; font-weight: 700; color: var(--accent); }

/* --- ALERT BANNERS --- */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.alert-amber { background: var(--amber-light); border: 1px solid #fde68a; color: #78350f; border-left: 3px solid var(--amber); }
.alert-red { background: var(--red-light); border: 1px solid #fecaca; color: #7f1d1d; border-left: 3px solid var(--red); }
.alert-green { background: var(--green-light); border: 1px solid #a7f3d0; color: #064e3b; border-left: 3px solid var(--green); }

/* --- PATIENT PHOTO UPLOAD --- */
.photo-upload { width: 90px; height: 90px; border-radius: 50%; border: 2px dashed var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; overflow: hidden; transition: border .15s; background: var(--bg); }
.photo-upload:hover { border-color: var(--accent); }
.photo-upload img { width: 100%; height: 100%; object-fit: cover; }

/* --- QUICK ACTIONS --- */
.quick-actions { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; }

/* --- LOGIN PAGE --- */
.login-page { min-height: 100vh; background: linear-gradient(135deg, #0f2744 0%, #1e3a5f 50%, #0f2744 100%); display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: var(--white); border-radius: 20px; padding: 40px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-icon { font-size: 40px; color: var(--accent); }
.login-title { font-size: 22px; font-weight: 700; margin-top: 8px; }
.login-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* --- MISC UTILITIES --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-4{margin-top:4px}.mt-8{margin-top:8px}.mt-12{margin-top:12px}.mt-16{margin-top:16px}.mt-20{margin-top:20px}
.mb-4{margin-bottom:4px}.mb-8{margin-bottom:8px}.mb-12{margin-bottom:12px}.mb-16{margin-bottom:16px}.mb-20{margin-bottom:20px}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.w-full { width: 100%; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-accent { color: var(--accent); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.text-center { text-align: center; }

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* --- PRINT --- */
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content { padding: 0; }
  .receipt-box { box-shadow: none; border: none; }
}

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { width: 60px; }
  .nav-link span, .logo-name, .logo-sub, .user-name, .user-role { display: none; }
  .nav-label { display: none; }
}