/* ===== EMR Lab Amanah — Purple/Gold Theme ===== */
:root {
  --purple-900: #2b1640;
  --purple-800: #3d2060;
  --purple-700: #512a7e;
  --purple-600: #6a2d9b;
  --purple-500: #7c3fb3;
  --purple-400: #9b6bcb;
  --purple-200: #e3d4f2;
  --purple-100: #f1e9fa;
  --gold: #c9a24a;
  --gold-soft: #e7d3a0;
  --ink: #241a30;
  --muted: #6b6378;
  --line: #ece6f3;
  --surface: #ffffff;
  --bg: #faf7fd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(43,22,64,.08);
  --shadow: 0 4px 16px rgba(43,22,64,.1);
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  margin: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--purple-600); text-decoration: none; transition: .2s; }
a:hover { color: var(--purple-700); }

/* ===== NAVBAR ===== */
.navbar {
  background: linear-gradient(135deg, var(--purple-900), var(--purple-700));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  height: 56px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 12px rgba(43,22,64,.2);
}
.nav-brand a { display: flex; align-items: center; gap: .5rem;
  color: #fff;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.2;
}
.nav-brand a:hover { text-decoration: none; opacity: .9; }
.nav-links { display: flex; align-items: center; gap: .25rem; }
.nav-links a {
  color: rgba(255,255,255,.78);
  padding: .35rem .65rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  transition: .2s;
}
.nav-links a:hover { color: #fff; background: rgba(255,255,255,.12); text-decoration: none; }
.nav-user { color: rgba(255,255,255,.65); font-size: .8rem; margin: 0 .5rem; }

/* ===== CONTAINER ===== */
.container { max-width: 1140px; margin: 2rem auto; padding: 0 1.75rem; }
.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem;
}
.page-header h1 {
  margin: 0; font-size: 1.55rem; font-weight: 700;
  color: var(--purple-900); letter-spacing: -.01em;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.card-header h2 { margin: 0; font-size: 1.1rem; font-weight: 700; color: var(--purple-800); }

/* ===== STATS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.4rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
  transition: .2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-number { font-size: 2.2rem; font-weight: 700; color: var(--purple-600); line-height: 1.1; }
.stat-label { font-size: .85rem; color: var(--muted); margin-top: .35rem; font-weight: 500; }

/* ===== TABLES ===== */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .65rem .85rem; text-align: left; border-bottom: 1px solid var(--line); font-size: .9rem; }
.table th {
  background: var(--purple-100);
  font-weight: 600; color: var(--purple-700);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
}
.table tr:hover { background: #faf7fd; }
.table .actions { white-space: nowrap; text-align: right; }

/* K/V Table */
.kv-table { width: 100%; }
.kv-table th {
  text-align: left; padding: .4rem .8rem; font-size: .85rem;
  color: var(--muted); width: 140px; vertical-align: top; font-weight: 600;
}
.kv-table td { padding: .35rem .8rem; }

/* ===== FORMS ===== */
.form-group { margin-bottom: .9rem; }
.form-group label {
  display: block; font-weight: 600; margin-bottom: .3rem;
  font-size: .85rem; color: var(--purple-800);
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: .55rem .75rem;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: .9rem; background: #fff; font-family: inherit;
  transition: .2s;
  color: var(--ink);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px rgba(124,63,179,.12);
}
.form-group textarea.mono { font-family: "SF Mono", "Courier New", monospace; font-size: .85rem; }
.form-row { display: flex; gap: .8rem; align-items: flex-start; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }
.form-actions { margin-top: 1rem; display: flex; gap: .6rem; }

.section-title {
  font-size: 1rem; font-weight: 700; color: var(--purple-700);
  padding: .4rem 0; margin: 1.5rem 0 .8rem;
  border-bottom: 2px solid var(--purple-400);
}

.search-bar { display: flex; gap: .5rem; margin-bottom: 1rem; }
.search-bar input {
  flex: 1; padding: .55rem .75rem;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  font-size: .9rem; background: #fff;
}
.search-bar input:focus { outline: none; border-color: var(--purple-500); }

/* ===== BUTTONS ===== */
.btn, .btn-sm, .btn-lg {
  display: inline-flex; align-items: center; gap: .35rem;
  cursor: pointer; border-radius: 999px; font-weight: 600;
  text-align: center; border: none; font-family: inherit;
  transition: .2s; line-height: 1.4;
}
.btn { padding: .5rem 1.2rem; font-size: .875rem; }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-lg { padding: .65rem 1.6rem; font-size: 1rem; }

.btn-primary {
  background: linear-gradient(135deg, var(--purple-600), var(--purple-500));
  color: #fff;
  box-shadow: 0 4px 12px rgba(106,45,155,.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(106,45,155,.4); text-decoration: none; color: #fff; }

.btn-outline {
  background: #fff; color: var(--purple-700);
  border: 1.5px solid var(--line);
}
.btn-outline:hover { background: var(--purple-100); border-color: var(--purple-400); text-decoration: none; }

.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); text-decoration: none; color: #fff; }

a.btn, a.btn-sm, a.btn-lg { text-decoration: none; }

/* ===== BADGES ===== */
.badge {
  display: inline-block; padding: .15rem .55rem;
  border-radius: 999px; font-size: .75rem; font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }

/* ===== FLASH ===== */
.flash-messages { margin-bottom: 1rem; }
.flash {
  padding: .7rem 1.1rem; border-radius: var(--radius-sm);
  margin-bottom: .4rem; font-size: .875rem; font-weight: 500;
}
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.flash-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.flash-info { background: #ede9fe; color: #5b21b6; border: 1px solid #ddd6fe; }

/* ===== LOGIN ===== */
.login-card {
  background: var(--surface);
  padding: 2.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  width: 100%; max-width: 420px;
}
.login-card h1 { margin: 0 0 .15rem; font-size: 1.5rem; font-weight: 700; color: var(--purple-800); letter-spacing: -.01em; }
.login-card .subtitle { color: var(--muted); margin-bottom: 1.5rem; font-size: .9rem; }

/* ===== UTIL ===== */
.text-muted { color: var(--muted); }
.text-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-1 { margin-right: .5rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .navbar { padding: 0 1rem; height: 48px; }
  .nav-links { gap: 0; }
  .nav-links a { font-size: .78rem; padding: .25rem .45rem; }
  .container { padding: 0 1rem; }
  .form-row { flex-direction: column; gap: 0; }
}
