/* CertaGigs base stylesheet — login + portal shell.
   Mobile-first; breakpoints at 640px and 1024px. */

:root {
  --brand:        #2f4f9e;   /* primary blue (buttons, badge)   */
  --brand-dark:   #24407f;
  --accent:       #e8a020;   /* gold accent                     */
  --bg:           #f4f5f8;
  --card:         #ffffff;
  --text:         #1d2433;
  --muted:        #6b7280;
  --border:       #d6dae3;
  --border-focus: #2f4f9e;
  --danger:       #d03030;
  --success:      #1a7f4b;
  --radius:       10px;
  --shadow:       0 8px 28px rgba(29, 36, 51, .10);
  --sidebar-w:    240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 16px;
}

/* ---------- Auth (login / forgot password) ---------- */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;   /* stack: login card on top, app-download card below */
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 36px 32px 40px;
  text-align: center;
}

.auth-card .logo { width: 220px; max-width: 80%; margin: 4px auto 14px; display: block; }

.role-badge {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  padding: 7px 22px;
  border-radius: 999px;
  margin-bottom: 22px;
  text-transform: uppercase;
}

.field { text-align: left; margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="email"] {
  width: 100%;
  padding: 11px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
  color: var(--text);
}

.field input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(47, 79, 158, .15);
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 14px;
  font-size: 14px;
}

.remember { display: flex; align-items: center; gap: 7px; color: var(--muted); }
.remember input { accent-color: var(--brand); width: 16px; height: 16px; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.form-error {
  color: var(--danger);
  font-size: 14px;
  min-height: 20px;
  margin: 2px 0 12px;
}

.btn {
  display: inline-block;
  width: 100%;
  padding: 13px 16px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}
.btn:hover:not(:disabled) { background: var(--brand-dark); }
.btn:disabled { opacity: .6; cursor: default; }

/* ---------- Portal shell ---------- */

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: #22304f;
  color: #cbd4e6;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform .2s ease;
  z-index: 40;
}
.sidebar.open { transform: translateX(0); }

.sidebar .brand {
  padding: 18px 20px;
  background: #1b2740;
}
.sidebar .brand img { width: 150px; filter: brightness(0) invert(1); }

.nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  color: #cbd4e6;
  font-size: 15px;
}
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav a.active {
  background: rgba(255,255,255,.10);
  color: #fff;
  border-left: 3px solid var(--accent);
  padding-left: 19px;
}

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

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 18px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.hamburger {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
  padding: 4px 8px;
}

.topbar .title { font-size: 17px; font-weight: 600; flex: 1; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
}
.user-chip .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }

.content { padding: 20px 18px 40px; }

.cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(29,36,51,.06);
  padding: 18px 20px;
}
.card h3 { margin: 0 0 4px; font-size: 14px; color: var(--muted); font-weight: 600; }
.card .big { font-size: 28px; font-weight: 700; }

.scrim {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 35;
  display: none;
}
.scrim.show { display: block; }

/* ---------- Tablet ≥640px ---------- */
@media (min-width: 640px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 26px 28px 48px; }
}

/* ---------- Desktop ≥1024px: sidebar pinned ---------- */
@media (min-width: 1024px) {
  .sidebar { transform: none; }
  .main { margin-left: var(--sidebar-w); }
  .hamburger, .scrim { display: none !important; }
  .cards { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Toolbar / buttons ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .spacer { flex: 1; }

.btn-auto { width: auto; padding: 10px 18px; font-size: 15px; }
.btn-sm {
  width: auto;
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
}
.btn-danger { background: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #a82323; }

/* ---------- Data table ---------- */

.table-wrap {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgba(29,36,51,.06);
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 640px;
}
table.data th, table.data td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: #fafbfd;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #f7f9fc; }
table.data td.actions { text-align: right; }
table.data td.actions .btn-sm { margin-left: 6px; }

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

/* ---------- Status badges ---------- */

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.badge.active   { background: #e2f5ea; color: var(--success); }
.badge.pending  { background: #fdf3df; color: #9a6b0c; }
.badge.inactive { background: #ececf0; color: var(--muted); }

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

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(24, 30, 44, .55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 14px;
  overflow-y: auto;
  z-index: 60;
}
.modal-overlay.show { display: flex; }

.modal {
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 560px;
  padding: 24px 24px 28px;
  margin: 4vh 0;
}
.modal h2 { margin: 0 0 18px; font-size: 19px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0 16px;
}
@media (min-width: 640px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .full { grid-column: 1 / -1; }
}

.modal .buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.field select {
  width: 100%;
  padding: 11px 10px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}
.field select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(47, 79, 158, .15);
  outline: none;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #22304f;
  color: #fff;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
  z-index: 80;
}
.toast.show { opacity: 1; }

/* ---------- Nav unread badge ---------- */

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #1d2433;
  font-size: 12px;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
  padding: 2px 7px;
  border-radius: 999px;
}
