/* assets/css/style.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #1a5276;
  --primary-lt: #eaf0f6;
  --accent:     #1a5276;
  --surface-0:  #f4f6f8;
  --surface-1:  #f9fafb;
  --surface-2:  #ffffff;
  --border:     #e2e8f0;
  --border-strong: #c9d4e0;
  --text:       #1a202c;
  --text-muted: #718096;
  --radius:     8px;
  --sidebar-w:  220px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--text); background: var(--surface-0); line-height: 1.6; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); background: var(--surface-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; }
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px; min-height: 100vh; }

/* Sidebar */
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid var(--border); }
.brand-icon { font-size: 22px; }
.brand-name { font-weight: 600; font-size: 14px; color: var(--primary); }
.brand-sub  { font-size: 11px; color: var(--text-muted); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-section { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .8px; padding: 14px 8px 4px; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--radius); color: var(--text-muted); text-decoration: none; font-size: 13px; margin-bottom: 2px; transition: background .15s, color .15s; }
.nav-item:hover { background: var(--surface-0); color: var(--text); }
.nav-item.active { background: var(--primary-lt); color: var(--primary); font-weight: 500; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }
.user-pill { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-lt); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* Page header */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.page-header h2 { font-size: 20px; font-weight: 600; }

/* Cards */
.card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 20px 22px; margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-header h3 { font-size: 15px; font-weight: 600; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.stat-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.icon-blue  { background: #ebf5fb; }
.icon-teal  { background: #e8f8f5; }
.icon-amber { background: #fef9e7; }
.icon-green { background: #eafaf1; }
.stat-value { font-size: 22px; font-weight: 600; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-muted); }

/* Table */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: var(--surface-1); }
th { padding: 9px 14px; text-align: left; font-weight: 600; font-size: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-1); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.field input, .field select, .field textarea {
  padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-size: 13px; font-family: inherit; background: var(--surface-2); color: var(--text);
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,82,118,.1);
}
.req { color: #e74c3c; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 7px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); font-size: 13px; font-family: inherit; cursor: pointer; text-decoration: none; color: var(--text); background: var(--surface-2); transition: background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--surface-0); border-color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: #154360; border-color: #154360; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge-success { background: #eafaf1; color: #1e8449; }
.badge-warning { background: #fef9e7; color: #b7770d; }
.badge-danger  { background: #fdedec; color: #c0392b; }
.badge-info    { background: #eaf4fb; color: #2471a3; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }
.alert-danger { background: #fdedec; border: 1px solid #f5b7b1; color: #c0392b; }
.alert-success { background: #eafaf1; border: 1px solid #a9dfbf; color: #1e8449; }

/* Auth */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--surface-0); }
.auth-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 36px 40px; width: 100%; max-width: 400px; }
.auth-logo { text-align: center; margin-bottom: 28px; }
.logo-icon { font-size: 36px; margin-bottom: 8px; }
.auth-logo h1 { font-size: 20px; color: var(--primary); }
.auth-logo p { font-size: 13px; color: var(--text-muted); }
.auth-foot { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 20px; }

/* Test grid (order page) */
.test-category { margin-bottom: 16px; }
.test-cat-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.test-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.test-card { display: flex; align-items: flex-start; gap: 8px; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.test-card:hover { border-color: var(--primary); background: var(--primary-lt); }
.test-card input[type=checkbox] { margin-top: 2px; accent-color: var(--primary); flex-shrink: 0; }
.test-card input:checked ~ .test-card-body .test-name { color: var(--primary); font-weight: 500; }
.test-name { font-size: 13px; font-weight: 400; }
.test-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Order summary */
.selected-list { min-height: 60px; margin-bottom: 12px; }
.selected-item { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.order-total-block { border-top: 1px solid var(--border); padding-top: 10px; }
.total-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 13px; }
.total-row input { border: 1px solid var(--border-strong); border-radius: 4px; padding: 3px 6px; font-size: 13px; }
.total-final { font-size: 15px; font-weight: 600; color: var(--primary); border-top: 1px solid var(--border-strong); padding-top: 8px; margin-top: 4px; }

/* Patient banner */
.patient-banner { display: flex; align-items: center; gap: 12px; background: var(--primary-lt); border: 1px solid #d0dce8; border-radius: var(--radius); padding: 10px 14px; }
.patient-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 15px; flex-shrink: 0; }

/* Patient search dropdown */
.search-dropdown { position: absolute; z-index: 99; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: 0 4px 16px rgba(0,0,0,.1); width: 100%; max-height: 220px; overflow-y: auto; }
.field { position: relative; }
.search-item { padding: 9px 14px; cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--border); }
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--primary-lt); }

/* Detail grid */
.detail-grid { display: flex; flex-direction: column; gap: 0; }
.detail-row { display: flex; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; gap: 12px; }
.detail-row:last-child { border-bottom: none; }
.detail-row > span:first-child { color: var(--text-muted); min-width: 120px; }

/* Utility */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
a { color: var(--primary); }
small { font-size: 11px; }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
