/* ============================================================
   PMS — Patient Management System Styles
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── 

   ─────────────────────────────────────────────
   CSS CUSTOM PROPERTIES
   ───────────────────────────────────────────── 
  --cyan:     #00d4ff;
 
	?? not yet
 --text-muted: #5a7a99;
  --green:    #26de81;
  --red:      #fc5c65;
  --amber:    #f7b731;
  --radius:       8px;


*/
:root {
  --navy-900: #0a1628; 
  --navy-800: #0d1f3c; 
  --navy-700: #112348;
  --navy-600: #1a3055; 
  --navy-500: #1e3a63;
 
  --cyan:     #00849e; 
  --cyan-dim: rgba(0,212,255,.15);
  
  
  --green:    #26de81; 
  --green-dim: rgba(38,222,129,.12);
  
  --red:      #fc5c65; 
  --red-dim:  rgba(252,92,101,.12);
  
  --orange:   #fd9644; 
  --yellow:   #f7b731; 
  --purple: #a55eea;
  
  --text-primary: #e8eaf0; 
  --text-secondary: #8fa3bc; 
  --text-muted: #5a7a99;
  
  --border: rgba(255,255,255,.08); 
  --border-hover: rgba(0,212,255,.3);
  --surface-1: #0d1f3c; 
  --surface-2: #112348; 
  --surface-3: #1a3055;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  
  --radius: 10px; 
  --radius-sm: 6px; 
  --radius-lg: 16px;
  
  --sidebar-w: 240px; 
  --topbar-h: 60px;
  --font-mono: 'IBM Plex Mono', monospace;
}

[data-theme="light"] {
  --navy-900: #f0f4f8; --navy-800: #ffffff; --navy-700: #f8fafc;
  --navy-600: #e8edf2; --navy-500: #dde4ec;
  --text-primary: #1a2744; --text-secondary: #4a6080; --text-muted: #8fa3bc;
  --border: rgba(0,0,0,.08); --border-hover: rgba(0,132,204,.3);
  --surface-1: #ffffff; --surface-2: #f8fafc; --surface-3: #eef2f7;
  --shadow: 0 2px 12px rgba(0,0,0,.1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  background: var(--navy-900); color: var(--text-primary);
  font-size: 14px; line-height: 1.6; min-height: 100vh;
}

/* ── Typography ─────────────────────────────────────────────── */
h1,h2,h3,h4 { font-weight: 600; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--font-mono); font-size:.85em; background: var(--surface-3);
       padding:1px 5px; border-radius:3px; color: var(--cyan); }
.text-muted  { color: var(--text-muted) !important; }
.text-sm     { font-size:.8rem; }
.text-xs     { font-size:.72rem; }
.fw-600      { font-weight:600; }
.mono        { font-family: var(--font-mono); }
.text-cyan   { color: var(--cyan); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-orange { color: var(--orange); }

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

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--navy-800);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed;
  top: 0; left: 0; height: 100vh; z-index: 100;
  transition: transform .3s ease;
}
.sidebar-logo {
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-text { font-size:1rem; font-weight:700; color:var(--cyan); }
.sidebar-logo .logo-sub  { font-size:.7rem; color:var(--text-muted); margin-top:2px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.nav-section { padding: 8px 16px 4px; font-size:.67rem; font-weight:700;
               text-transform:uppercase; letter-spacing:.1em; color:var(--text-muted); }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: var(--text-secondary);
  transition: all .2s; font-size:.875rem; cursor:pointer; text-decoration:none;
}
.nav-link:hover { background: var(--cyan-dim); color: var(--cyan); text-decoration:none; }
.nav-link.active { background: var(--cyan-dim); color: var(--cyan); border-right:3px solid var(--cyan); }
.nav-link i { width:18px; text-align:center; font-size:.875rem; }
.nav-badge { margin-left:auto; background:var(--red); color:#fff;
             font-size:.65rem; font-weight:700; padding:1px 6px;
             border-radius:10px; min-width:18px; text-align:center; }

.sidebar-user {
  padding: 14px 16px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--cyan-dim); border: 1px solid var(--cyan);
  display: flex; align-items: center; justify-content: center;
  color: var(--cyan); font-weight:700; font-size:.8rem; flex-shrink:0;
}
.user-info .user-name  { font-size:.8rem; font-weight:600; }
.user-info .user-role  { font-size:.7rem; color:var(--text-muted); }

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h); background: var(--navy-800);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px;
  z-index: 90;
}
.topbar-search {
  flex: 1; max-width: 420px; position: relative;
}
.topbar-search input {
  width:100%; padding:8px 12px 8px 36px;
  background: var(--surface-3); border:1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size:.85rem; outline:none; transition:.2s;
}
.topbar-search input:focus { border-color: var(--cyan); }
.topbar-search .search-icon { position:absolute; left:10px; top:50%; transform:translateY(-50%); color:var(--text-muted); font-size:.8rem; }
#searchResults {
  position:absolute; top:calc(100% + 6px); left:0; right:0;
  background:var(--navy-800); border:1px solid var(--border);
  border-radius:var(--radius); box-shadow:var(--shadow);
  display:none; z-index:200; max-height:320px; overflow-y:auto;
}
#searchResults.show { display:block; }
.search-result-item {
  display:flex; align-items:center; gap:10px; padding:10px 14px;
  border-bottom:1px solid var(--border); cursor:pointer;
  color:var(--text-primary); text-decoration:none; transition:.15s;
}
.search-result-item:hover { background:var(--surface-3); }
.search-result-icon { width:28px; height:28px; background:var(--cyan-dim);
  border-radius:6px; display:flex; align-items:center; justify-content:center;
  color:var(--cyan); font-size:.8rem; flex-shrink:0; }

.topbar-actions { display:flex; align-items:center; gap:8px; margin-left:auto; }
.topbar-btn {
  width:34px; height:34px; border-radius:var(--radius-sm);
  background:var(--surface-3); border:1px solid var(--border);
  cursor:pointer; display:flex; align-items:center; justify-content:center;
  color:var(--text-secondary); font-size:.85rem; transition:.2s; position:relative;
}
.topbar-btn:hover { border-color:var(--cyan); color:var(--cyan); }
.notif-dot { position:absolute; top:4px; right:4px; width:8px; height:8px;
             background:var(--red); border-radius:50%; border:2px solid var(--navy-800); }

/* ── Main content ─────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w); margin-top: var(--topbar-h);
  padding: 28px; flex: 1; min-height: calc(100vh - var(--topbar-h));
}

/* ── Page header ──────────────────────────────────────────────── */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 1.6rem; font-weight: 700; }
.page-subtitle { color: var(--text-muted); font-size: .875rem; margin-top: 2px; }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-body   { padding: 20px; }

/* ── Stats grid ──────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap:16px; margin-bottom:24px; }
.stat-card {
  background: var(--surface-1); border:1px solid var(--border);
  border-radius: var(--radius); padding:20px;
  display:flex; flex-direction:column; gap:6px;
}
.stat-value { font-size:1.8rem; font-weight:700; color:var(--cyan); }
.stat-label { font-size:.78rem; color:var(--text-muted); text-transform:uppercase; letter-spacing:.05em; }
.stat-trend { font-size:.75rem; color:var(--green); }

/* ── Grid helpers ─────────────────────────────────────────────── */
.grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.grid-3 { display:grid; grid-template-columns:repeat(3,1fr); gap:16px; }
.grid-4 { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm); font-size:.85rem;
  font-weight:600; cursor:pointer; transition:.2s; border:1px solid transparent;
  text-decoration:none; white-space:nowrap;
}
.btn:hover { text-decoration:none; filter:brightness(1.1); }
.btn:disabled { opacity:.5; cursor:not-allowed; filter:none; }
.btn-primary   { background:var(--cyan);   color:var(--navy-900); border-color:var(--cyan); }
.btn-success   { background:var(--green);  color:var(--navy-900); border-color:var(--green); }
.btn-danger    { background:var(--red);    color:#fff;            border-color:var(--red); }
.btn-warning   { background:var(--yellow); color:var(--navy-900); border-color:var(--yellow); }
.btn-secondary { background:var(--surface-3); color:var(--text-primary); border-color:var(--border); }
.btn-ghost     { background:transparent; color:var(--text-secondary); border-color:var(--border); }
.btn-ghost:hover { color:var(--text-primary); }
.btn-sm  { padding:5px 10px; font-size:.78rem; }
.btn-lg  { padding:11px 24px; font-size:.95rem; }
.btn-icon { padding:7px; width:32px; height:32px; justify-content:center; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display:inline-flex; align-items:center; padding:2px 8px;
  border-radius:20px; font-size:.7rem; font-weight:700;
  text-transform:uppercase; letter-spacing:.04em;
}
.badge-secondary { background:var(--surface-3); color:var(--text-muted); }
.badge-success   { background:var(--green-dim); color:var(--green); }
.badge-danger    { background:var(--red-dim);   color:var(--red); }
.badge-warning   { background:rgba(247,183,49,.15); color:var(--yellow); }
.badge-info      { background:var(--cyan-dim);  color:var(--cyan); }
.badge-purple    { background:rgba(165,94,234,.15); color:var(--purple); }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group  { margin-bottom:16px; }
.form-label  { display:block; font-size:.82rem; font-weight:600;
               color:var(--text-secondary); margin-bottom:5px; }
.form-control {
  width:100%; padding:9px 12px; background:var(--surface-3);
  border:1px solid var(--border); border-radius:var(--radius-sm);
  color:var(--text-primary); font-size:.875rem; outline:none; transition:.2s;
  font-family:inherit;
}
.form-control:focus { border-color:var(--cyan); background:var(--surface-2); }
textarea.form-control { resize:vertical; min-height:80px; }
select.form-control option { background:var(--navy-800); }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.form-grid-3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:12px; }
.form-note { font-size:.75rem; color:var(--text-muted); margin-top:4px; }
.form-check { display:flex; align-items:center; gap:8px; cursor:pointer; }
.form-check input { width:auto; cursor:pointer; }
.required::after { content:' *'; color:var(--red); }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrapper { overflow-x:auto; }
.data-table { width:100%; border-collapse:collapse; }
.data-table th {
  padding:10px 14px; background:var(--surface-3);
  font-size:.72rem; font-weight:700; text-transform:uppercase;
  letter-spacing:.06em; color:var(--text-muted);
  border-bottom:1px solid var(--border); text-align:left;
  white-space:nowrap; cursor:pointer; user-select:none;
}
.data-table td { padding:12px 14px; border-bottom:1px solid var(--border);
  vertical-align:middle; }
.data-table tr:last-child td { border-bottom:none; }
.data-table tr:hover td { background:var(--surface-3); }
.data-table .empty-state { text-align:center; padding:48px; color:var(--text-muted); }

/* ── Calendar ────────────────────────────────────────────────── */
.cal-header { display:flex; align-items:center; justify-content:space-between;
  padding:14px 20px; border-bottom:1px solid var(--border); }
.cal-title   { font-size:1.1rem; font-weight:700; }
.cal-nav     { display:flex; gap:6px; }
.cal-grid    { display:grid; grid-template-columns:repeat(7,1fr); }
.cal-day-header { text-align:center; padding:8px 0; font-size:.72rem;
  font-weight:700; text-transform:uppercase; color:var(--text-muted);
  border-bottom:1px solid var(--border); }
.cal-day {
  min-height:100px; padding:6px; border-right:1px solid var(--border);
  border-bottom:1px solid var(--border); position:relative; transition:.15s;
  cursor:default;
}
.cal-day:nth-child(7n) { border-right:none; }
.cal-day.other-month   { opacity:.35; }
.cal-day.today .cal-date { background:var(--cyan); color:var(--navy-900);
  border-radius:50%; width:24px; height:24px; display:flex;
  align-items:center; justify-content:center; font-weight:700; }
.cal-day:hover { background:var(--surface-3); }
.cal-date  { font-size:.78rem; font-weight:600; margin-bottom:4px; }
.cal-event {
  font-size:.7rem; padding:2px 6px; border-radius:3px;
  margin-bottom:2px; overflow:hidden; white-space:nowrap;
  text-overflow:ellipsis; cursor:pointer; color:#fff;
}
.cal-more  { font-size:.68rem; color:var(--cyan); cursor:pointer; }

/* ── Timeline / Agenda ───────────────────────────────────────── */
.agenda-item {
  display:flex; gap:14px; padding:12px 0; border-bottom:1px solid var(--border);
  align-items:flex-start;
}
.agenda-time { min-width:70px; font-size:.8rem; color:var(--text-muted);
  font-family:var(--font-mono); padding-top:2px; }
.agenda-bar  { width:4px; border-radius:2px; min-height:40px; flex-shrink:0; }
.agenda-content { flex:1; }
.agenda-title  { font-weight:600; font-size:.875rem; }
.agenda-meta   { font-size:.75rem; color:var(--text-muted); margin-top:2px; }

/* ── Patient card ────────────────────────────────────────────── */
.patient-card {
  background:var(--surface-1); border:1px solid var(--border);
  border-radius:var(--radius); padding:18px; transition:.2s;
  display:flex; flex-direction:column; gap:8px;
}
.patient-card:hover { border-color:var(--border-hover); box-shadow:var(--shadow); }
.patient-avatar {
  width:48px; height:48px; border-radius:50%;
  background:var(--cyan-dim); border:2px solid var(--cyan);
  display:flex; align-items:center; justify-content:center;
  color:var(--cyan); font-weight:700; font-size:1rem; flex-shrink:0;
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position:fixed; inset:0; background:rgba(0,0,0,.6);
  display:flex; align-items:center; justify-content:center;
  z-index:1000; padding:20px;
}
.modal {
  background:var(--navy-800); border:1px solid var(--border);
  border-radius:var(--radius-lg); width:100%; max-width:580px;
  max-height:90vh; display:flex; flex-direction:column;
  box-shadow:var(--shadow);
}
.modal-lg  { max-width:780px; }
.modal-xl  { max-width:1000px; }
.modal-header {
  display:flex; justify-content:space-between; align-items:center;
  padding:18px 24px; border-bottom:1px solid var(--border); flex-shrink:0;
}
.modal-title  { font-size:1.05rem; font-weight:700; }
.modal-close  { background:none; border:none; color:var(--text-muted);
  cursor:pointer; font-size:1.1rem; padding:4px; border-radius:4px;
  transition:.2s; }
.modal-close:hover { color:var(--text-primary); background:var(--surface-3); }
.modal-body   { padding:24px; overflow-y:auto; flex:1; }
.modal-footer { padding:16px 24px; border-top:1px solid var(--border);
  display:flex; justify-content:flex-end; gap:8px; flex-shrink:0; }
#globalModal { display:none; }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs { display:flex; gap:4px; border-bottom:1px solid var(--border); margin-bottom:20px; }
.tab  { padding:10px 16px; cursor:pointer; color:var(--text-muted);
  font-size:.875rem; font-weight:600; border-bottom:2px solid transparent;
  transition:.2s; }
.tab.active { color:var(--cyan); border-bottom-color:var(--cyan); }
.tab:hover:not(.active) { color:var(--text-primary); }
.tab-panel { display:none; }
.tab-panel.active { display:block; }

/* ── Timeline ────────────────────────────────────────────────── */
.timeline { position:relative; padding-left:28px; }
.timeline::before { content:''; position:absolute; left:8px; top:0; bottom:0;
  width:2px; background:var(--border); }
.timeline-item { position:relative; margin-bottom:20px; }
.timeline-dot { position:absolute; left:-24px; top:4px; width:14px; height:14px;
  border-radius:50%; background:var(--cyan); border:2px solid var(--navy-800); }
.timeline-content { background:var(--surface-3); border-radius:var(--radius-sm);
  padding:12px 16px; }
.timeline-date  { font-size:.72rem; color:var(--text-muted); margin-bottom:4px; }
.timeline-title { font-weight:600; font-size:.875rem; }

/* ── Alert / toast ───────────────────────────────────────────── */
.toast-container {
  position:fixed; top:72px; right:20px; z-index:9000;
  display:flex; flex-direction:column; gap:8px; pointer-events:none;
}
.toast {
  min-width:300px; max-width:420px; padding:12px 16px;
  border-radius:var(--radius-sm); border-left:4px solid var(--cyan);
  background:var(--navy-800); box-shadow:var(--shadow);
  display:flex; align-items:center; gap:10px; pointer-events:all;
  animation:slideIn .3s ease; font-size:.875rem;
}
.toast.success { border-color:var(--green); }
.toast.error   { border-color:var(--red); }
.toast.warning { border-color:var(--yellow); }
@keyframes slideIn { from { transform:translateX(100%); opacity:0; } to { transform:none; opacity:1; } }

/* ── Toolbar ─────────────────────────────────────────────────── */
.toolbar { display:flex; gap:10px; margin-bottom:16px; flex-wrap:wrap; align-items:center; }
.toolbar-search { position:relative; }
.toolbar-search input { padding:8px 12px 8px 32px; }
.toolbar-search .fa { position:absolute; left:10px; top:50%; transform:translateY(-50%);
  color:var(--text-muted); font-size:.8rem; }
.toolbar-sep  { width:1px; height:28px; background:var(--border); }
.toolbar-right { margin-left:auto; display:flex; gap:8px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main-content { margin-left:0; padding:16px; }
  .topbar { left:0; padding:0 14px; }
  .grid-2,.grid-3,.grid-4 { grid-template-columns:1fr; }
  .form-grid,.form-grid-3 { grid-template-columns:1fr; }
  .page-header { flex-direction:column; }
  .stats-grid  { grid-template-columns:1fr 1fr; }
  .cal-day { min-height:60px; }
  .cal-event { display:none; }
  .modal { max-height:95vh; }
  .data-table th,.data-table td { padding:8px 10px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns:1fr; }
  .topbar-search { display:none; }
}

/* ── Utilities ───────────────────────────────────────────────── */
.d-flex          { display:flex; }
.align-center    { align-items:center; }
.justify-between { justify-content:space-between; }
.gap-8   { gap:8px; }  .gap-12  { gap:12px; } .gap-16  { gap:16px; }
.mt-8    { margin-top:8px; } .mt-16 { margin-top:16px; } .mt-24 { margin-top:24px; }
.mb-8    { margin-bottom:8px; } .mb-16 { margin-bottom:16px; }
.p-16    { padding:16px; } .p-20  { padding:20px; } .p-24 { padding:24px; }
.w-full  { width:100%; }
.text-right { text-align:right; }
.text-center { text-align:center; }
.hidden  { display:none !important; }
.separator { border:none; border-top:1px solid var(--border); margin:16px 0; }
.spinner { width:20px; height:20px; border:2px solid var(--border);
  border-top-color:var(--cyan); border-radius:50%; animation:spin .7s linear infinite;
  display:inline-block; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .sidebar,.topbar,.topbar-actions,.no-print { display:none !important; }
  .main-content { margin:0 !important; padding:0 !important; }
  body,.card { background:#fff !important; color:#000 !important; }
  .card { border:1px solid #ccc !important; box-shadow:none !important; }
}
