/* ============================================================
   PM PAK - Pakistan Practice Management
   Shared design system
   ============================================================ */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --border: #e3e7ed;
  --text: #1f2430;
  --text-muted: #6b7280;
  --text-faint: #9aa2b1;

  --brand: #12805c;          /* Pakistan green */
  --brand-dark: #0d6146;
  --brand-soft: #e4f4ee;

  --danger: #d1392b;
  --danger-soft: #fdeceb;
  --warning: #c98a12;
  --warning-soft: #fdf3e1;
  --success: #1f9d6f;
  --success-soft: #e6f6ee;
  --info: #2953d1;
  --info-soft: #eaf0ff;
  --purple: #7a4bd1;
  --purple-soft: #f1ebfb;
  --orange: #d1712b;
  --orange-soft: #fdf0e6;

  --radius-sm: 6px;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 33, 0.06);
  --shadow: 0 4px 14px rgba(20, 24, 33, 0.08);
  --shadow-lg: 0 12px 32px rgba(20, 24, 33, 0.14);

  --sidebar-w: 236px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Inter, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Layout shell ---------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #14251f;
  color: #cbd8d2;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
}

.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 20px;
  color: #fff; font-weight: 600; font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 14px;
}

.sidebar .brand .logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), #3fbf90);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: #fff;
}

.nav-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: #6e8279; padding: 14px 10px 6px;
}

.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--radius-sm);
  color: #cbd8d2; font-size: 13.5px; margin-bottom: 2px;
}
.nav-link:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.nav-link.active { background: var(--brand); color: #fff; }
.nav-link .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.6; flex-shrink: 0; }

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

.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); }
.user-chip .meta { overflow: hidden; }
.user-chip .name { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .role { font-size: 11.5px; color: #8ba095; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12.5px; flex-shrink: 0;
}

.logout-btn {
  width: 100%; margin-top: 10px;
  background: transparent; border: 1px solid rgba(255,255,255,0.12);
  color: #cbd8d2; padding: 8px; border-radius: var(--radius-sm); font-size: 12.5px;
}
.logout-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 650; }
.topbar .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.content { padding: 24px 28px 40px; flex: 1; }

/* ---------- Cards / generic ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px 20px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1100px) {
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .sidebar { width: 100%; }
  .app-shell { flex-direction: column; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
}

.stat-tile { padding: 16px 18px; }
.stat-tile .stat-value { font-size: 26px; font-weight: 700; }
.stat-tile .stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.section-title { margin: 0 0 14px; font-size: 15px; font-weight: 650; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
}
.badge-blue   { background: var(--info-soft);    color: var(--info); }
.badge-green  { background: var(--success-soft); color: var(--success); }
.badge-purple { background: var(--purple-soft);  color: var(--purple); }
.badge-orange { background: var(--orange-soft);  color: var(--orange); }
.badge-red    { background: var(--danger-soft);  color: var(--danger); }
.badge-yellow { background: var(--warning-soft); color: var(--warning); }
.badge-gray   { background: #eef0f4;             color: var(--text-muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 550;
}
.btn:hover { background: var(--surface-alt); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: #f4c9c4; }
.btn-danger:hover { background: var(--danger-soft); }

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="number"], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13.5px; color: var(--text); background: var(--surface);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}

.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.form-help { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ---------- Tables ---------- */

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-muted); font-weight: 600;
  padding: 10px 14px; background: var(--surface-alt); border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-alt); }

th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { background: #eef2f7; }
th.sortable .sort-arrow { color: #94a3b8; font-size: 11px; margin-left: 4px; }
th.sortable .sort-arrow.active { color: var(--brand); font-weight: 700; }

.empty-state { padding: 34px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ---------- Checkbox groups ---------- */

.check-group {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; max-height: 150px; overflow-y: auto;
}
.check-group label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 400; color: var(--text); cursor: pointer; margin: 0;
}
.check-group input[type="checkbox"] { width: auto; }
.check-group .none { color: var(--text-faint); font-size: 12.5px; font-style: italic; }

/* ---------- Modal ---------- */

.modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px;
}
.modal {
  background: #fff; border-radius: var(--radius); width: min(620px, 96vw);
  max-height: 90vh; overflow: auto; padding: 22px 24px; box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 16px; font-size: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ---------- Credential table bits ---------- */

.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  background: var(--surface); border: 1px solid var(--border);
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 550; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { background: var(--surface-alt); color: var(--text); }
.tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.tab .count {
  background: rgba(0,0,0,0.08); border-radius: 999px;
  padding: 0 7px; font-size: 11px; font-weight: 600; line-height: 18px;
}
.tab.active .count { background: rgba(255,255,255,0.22); }

.cred-cell { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; }
.cred-cell .val {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
}
.cred-cell .val.empty { color: var(--text-faint); font-style: italic; font-family: inherit; }

.icon-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 4px;
  padding: 2px 6px; font-size: 11px; line-height: 1.4; color: var(--text-muted);
}
.icon-btn:hover { background: #f1f5f9; color: var(--text); }

.copied-tip {
  position: fixed; background: #0f172a; color: #fff; font-size: 11px;
  padding: 5px 9px; border-radius: 4px; z-index: 99999; pointer-events: none;
  opacity: 0; transition: opacity 0.15s;
}
.copied-tip.show { opacity: 1; }

.note { font-size: 12px; color: var(--text-muted); }

/* ---------- Access denied ---------- */

.access-banner {
  background: var(--danger-soft); color: var(--danger); border: 1px solid #f4c9c4;
  border-radius: var(--radius); padding: 24px; text-align: center;
  max-width: 480px; margin: 60px auto;
}
.access-banner h2 { margin-top: 0; }
.access-banner a { color: var(--danger); font-weight: 600; }

/* ---------- Login page ---------- */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(160deg, #14251f 0%, #1d3a2e 55%, #12805c 100%);
}
.login-card {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: min(420px, 100%); padding: 32px;
}
.login-card .logo-mark {
  width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), #3fbf90);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px; margin-bottom: 16px;
}
.login-card h1 { font-size: 21px; margin: 0 0 4px; }
.login-card .sub { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }

.alert { border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; margin-bottom: 14px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f4c9c4; }
.alert-info  { background: var(--info-soft);  color: var(--info);  border: 1px solid #cddbfa; }
