/* =====================================================
   Mediks Platform Admin — admin.css
   Brand: #0078FF blue, #0D1B3E dark sidebar
   Fonts: IBM Plex Sans (body), Space Grotesk (display)
   PHP 7.2 compatible server
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --blue:         #0078FF;
  --blue-light:   #E6F1FF;
  --blue-dark:    #0055CC;
  --sidebar-bg:   #0D1B3E;
  --surface:      #F4F5F7;
  --surface2:     #ECEEF2;
  --border:       #DDE1E9;
  --border2:      #C5CAD5;
  --text:         #111827;
  --text2:        #4B5563;
  --text3:        #9CA3AF;
  --white:        #FFFFFF;
  --green:        #16A34A;
  --green-light:  #DCFCE7;
  --amber:        #D97706;
  --amber-light:  #FEF3C7;
  --red:          #DC2626;
  --red-light:    #FEE2E2;
  --purple:       #7C3AED;
  --purple-light: #EDE9FE;
  --radius:       10px;
  --radius-sm:    6px;
  --sidebar-w:    220px;
}

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

body {
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
  background: var(--surface);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }

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

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}

.sidebar-logo-dot {
  width: 28px; height: 28px;
  background: var(--blue);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-dot svg { width: 15px; height: 15px; fill: white; }

.sidebar-logo-text {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px; font-weight: 600;
  color: white; line-height: 1.2;
}

.sidebar-logo-sub {
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
}

.sidebar-section {
  padding: 16px 12px 6px;
  font-size: 10px; font-weight: 600;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
}

.sidebar-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: rgba(255,255,255,0.6);
  font-size: 13px; font-weight: 400;
  transition: background 0.15s, color 0.15s;
}

.sidebar-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-item:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.9); }
.sidebar-item.active { background: var(--blue); color: white; }

.sidebar-badge {
  margin-left: auto;
  background: #DC2626;
  color: white;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 10px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-footer a {
  color: rgba(255,255,255,0.5);
  font-size: 12px;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}

.sidebar-footer a:hover { color: rgba(255,255,255,0.8); }
.sidebar-footer a svg { width: 14px; height: 14px; }

/* ── Main ─────────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}

.topbar-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px; font-weight: 600;
  color: var(--text); flex: 1;
}

.topbar-title span {
  font-size: 13px; font-weight: 400;
  color: var(--text3); margin-left: 6px;
  font-family: 'IBM Plex Sans', sans-serif;
}

.topbar-admin {
  font-size: 12px; color: var(--text3);
  display: flex; align-items: center; gap: 6px;
}

.topbar-admin strong { color: var(--text2); }

/* ── Page content ─────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap; border: none;
  transition: background 0.15s, opacity 0.15s;
}

.btn svg { width: 14px; height: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary  { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-outline  { background: var(--white); border: 1px solid var(--border); color: var(--text2); }
.btn-outline:hover { border-color: var(--border2); background: var(--surface); }
.btn-danger   { background: var(--red); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }

/* ── Stat cards ──────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 20px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.stat-label {
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text3); margin-bottom: 6px;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 26px; font-weight: 700;
  color: var(--text); line-height: 1;
}

.stat-value.green  { color: var(--green); }
.stat-value.amber  { color: var(--amber); }
.stat-value.blue   { color: var(--blue); }
.stat-value.red    { color: var(--red); }
.stat-value.purple { color: var(--purple); }

/* ── Card ─────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.card-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px; font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
}

/* ── Table ───────────────────────────────────────────── */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  background: var(--surface);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th.num    { text-align: right; }
thead th.center { text-align: center; }

tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #FAFBFC; }

tbody td { padding: 10px 14px; vertical-align: middle; }

/* ── Badges ───────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 10px;
  white-space: nowrap;
}

.badge-live     { color: #15803D; background: #DCFCE7; }
.badge-inactive { color: var(--text3); background: var(--surface2); }
.badge-amber    { color: var(--amber); background: var(--amber-light); }
.badge-red      { color: var(--red); background: var(--red-light); }
.badge-blue     { color: var(--blue-dark); background: var(--blue-light); }
.badge-purple   { color: var(--purple); background: var(--purple-light); }

/* ── Filters ─────────────────────────────────────────── */
.filters {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; flex-wrap: wrap;
}

.search-box { position: relative; flex: 1; min-width: 200px; max-width: 300px; }

.search-box svg {
  position: absolute; left: 9px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text3); pointer-events: none;
}

.search-box input {
  width: 100%; padding: 7px 9px 7px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit;
  background: var(--surface); outline: none; color: var(--text);
}

.search-box input:focus { border-color: var(--blue); background: white; }

.filter-select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit;
  background: var(--surface); outline: none;
  cursor: pointer; color: var(--text);
}

.filter-meta { margin-left: auto; font-size: 12px; color: var(--text3); white-space: nowrap; }

/* ── Pagination ───────────────────────────────────────── */
.pagination {
  background: var(--white);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text3);
}

.page-btns { display: flex; gap: 4px; }

.page-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-size: 12px; cursor: pointer;
  font-family: inherit; color: var(--text2);
  transition: background 0.1s;
}

.page-btn:hover   { background: var(--surface); }
.page-btn.active  { background: var(--blue); color: white; border-color: var(--blue); }
.page-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Flash messages ───────────────────────────────────── */
.flash {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}

.flash-success { background: var(--green-light); color: var(--green); }
.flash-error   { background: var(--red-light); color: var(--red); }
.flash-info    { background: var(--blue-light); color: var(--blue-dark); }
.flash-warning { background: var(--amber-light); color: var(--amber); }

/* ── Login ────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
}

.login-card {
  width: 100%; max-width: 380px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
}

.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }

.login-logo-dot {
  width: 36px; height: 36px;
  background: var(--blue); border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
}

.login-logo-dot svg { width: 20px; height: 20px; fill: white; }

.login-logo-text { font-family: 'Space Grotesk', sans-serif; font-size: 18px; font-weight: 700; color: var(--text); }
.login-logo-sub  { font-size: 11px; color: var(--text3); display: block; line-height: 1.2; }
.login-title     { font-family: 'Space Grotesk', sans-serif; font-size: 20px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.login-sub       { font-size: 13px; color: var(--text3); margin-bottom: 24px; }

.form-group  { margin-bottom: 16px; }
.form-label  { display: block; font-size: 12px; font-weight: 500; color: var(--text2); margin-bottom: 6px; }
.form-row    { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }

.form-input {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit;
  color: var(--text); background: var(--surface);
  outline: none; transition: border-color 0.15s;
}

.form-input:focus { border-color: var(--blue); background: white; }
.form-input.error { border-color: var(--red); }
.form-error { font-size: 12px; color: var(--red); margin-top: 5px; }

/* ── Utility ──────────────────────────────────────────── */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.mt-4  { margin-top: 16px; }
.mt-6  { margin-top: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── PII masked ───────────────────────────────────────── */
.pii-masked { color: var(--text3); font-style: italic; letter-spacing: 1px; }
