/* ── Brand tokens ─────────────────────────────────────────────────────────── */
:root {
  --teal:       #0F5D4E;
  --teal-dark:  #0A3D32;
  --teal-light: #E6F4F1;
  --gold:       #D69A3D;
  --gold-light: #FDF5E6;
  --bg:         #F4F7F6;
  --sidebar-w:  260px;
  --topbar-h:   60px;
  --radius:     10px;
  --shadow:     0 2px 12px rgba(0,0,0,.08);
}

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

body {
  font-family: 'Manrope', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: #1a1a2e;
  min-height: 100vh;
}

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

/* ── Bootstrap overrides ──────────────────────────────────────────────────── */
.btn-primary {
  background: var(--teal); border-color: var(--teal);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--teal-dark); border-color: var(--teal-dark);
}
.btn-outline-primary {
  color: var(--teal); border-color: var(--teal);
}
.btn-outline-primary:hover {
  background: var(--teal); border-color: var(--teal);
}
.btn-gold {
  background: var(--gold); border-color: var(--gold); color: #fff;
}
.btn-gold:hover { background: #b8832e; border-color: #b8832e; color: #fff; }

.badge-teal  { background: var(--teal);  color:#fff; }
.badge-gold  { background: var(--gold);  color:#fff; }

.form-control:focus, .form-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 .2rem rgba(15,93,78,.2);
}

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--teal-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 1000;
  transition: transform .25s ease;
}
.sidebar-brand {
  padding: 20px 24px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand .brand-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.3px;
}
.sidebar-brand .brand-sub {
  font-size: .7rem;
  color: rgba(255,255,255,.55);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.sidebar-nav .nav-section {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255,255,255,.35);
  padding: 16px 24px 4px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 24px;
  color: rgba(255,255,255,.75);
  font-size: .88rem;
  font-weight: 500;
  border-radius: 0;
  transition: background .15s, color .15s;
  position: relative;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration:none; }
.sidebar-nav a.active {
  background: rgba(255,255,255,.13);
  color: #fff;
}
.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}
.sidebar-nav a i { font-size: 1rem; opacity: .8; }
.sidebar-nav .badge { font-size: .65rem; padding: 2px 6px; }

.sidebar-user {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-user .avatar {
  width: 34px; height: 34px;
  background: var(--gold);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; color: #fff;
  flex-shrink: 0;
}
.sidebar-user .name {
  font-size: .82rem; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .role-label {
  font-size: .68rem; color: rgba(255,255,255,.5); text-transform: capitalize;
}

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

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e8eeec;
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--teal-dark);
  flex: 1;
}
.topbar .btn-icon {
  background: none; border: none;
  color: #666; cursor: pointer;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  transition: background .15s;
}
.topbar .btn-icon:hover { background: var(--teal-light); color: var(--teal); }

/* Page body */
.page-body {
  padding: 28px;
  flex: 1;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  border: 1px solid #e0eae7;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: #fff;
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #e0eae7;
  padding: 16px 20px;
  font-weight: 700;
  font-size: .93rem;
  color: var(--teal-dark);
  border-radius: var(--radius) var(--radius) 0 0 !important;
}

/* Stat tiles */
.stat-tile {
  background: #fff;
  border: 1px solid #e0eae7;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-tile .stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--teal-dark);
  line-height: 1.1;
}
.stat-tile .stat-label {
  font-size: .78rem;
  font-weight: 600;
  color: #6b7b74;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 4px;
}
.stat-tile .stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  background: var(--teal-light);
  color: var(--teal);
}
.stat-tile.gold .stat-icon { background: var(--gold-light); color: var(--gold); }
.stat-tile.gold .stat-value { color: #8a6120; }

/* ── Status badges ──────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 700; text-transform: capitalize;
}
.status-pending    { background: #FFF3CD; color: #856404; }
.status-uploaded   { background: #CCE5FF; color: #004085; }
.status-approved   { background: #D4EDDA; color: #155724; }
.status-rejected   { background: #F8D7DA; color: #721c24; }
.status-certify    { background: #D4EDDA; color: #155724; }
.status-hold       { background: #FFF3CD; color: #856404; }
.status-certified  { background: #D4EDDA; color: #155724; }
.status-active     { background: #D4EDDA; color: #155724; }
.status-todo       { background: #e2e3e5; color: #383d41; }
.status-in_progress { background: #CCE5FF; color: #004085; }
.status-done       { background: #D4EDDA; color: #155724; }
.status-open       { background: #CCE5FF; color: #004085; }
.status-resolved   { background: #D4EDDA; color: #155724; }
.status-closed     { background: #e2e3e5; color: #383d41; }
.status-training   { background: #d0e8ff; color: #004085; }
.status-pending_payment    { background: #FFF3CD; color: #856404; }
.status-pending_verification { background: #CCE5FF; color: #004085; }
.status-pending_discussion { background: #e2d0ff; color: #4a1f7a; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table > thead > tr > th {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #6b7b74;
  background: #f8faf9;
  border-bottom: 2px solid #e0eae7;
}
.table > tbody > tr:hover { background: #f4f9f7; }
.table td { vertical-align: middle; font-size: .88rem; }

/* ── Auth pages ───────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--teal-dark) 0%, var(--teal) 60%, #1a7a6a 100%);
  padding: 24px;
}
.auth-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo .logo-mark {
  width: 56px; height: 56px;
  background: var(--teal);
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.auth-logo .logo-mark i { font-size: 1.8rem; color: #fff; }
.auth-logo h1 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--teal-dark);
  margin: 0;
}
.auth-logo p {
  font-size: .82rem;
  color: #777;
  margin: 4px 0 0;
}

/* ── Public website ───────────────────────────────────────────────────────── */
.pub-hero {
  background: linear-gradient(135deg, var(--teal-dark) 0%, var(--teal) 100%);
  color: #fff;
  padding: 80px 0;
}
.pub-hero h1 { font-size: 2.4rem; font-weight: 800; }
.pub-hero p  { font-size: 1.1rem; opacity: .85; }
.pub-nav {
  background: var(--teal-dark);
  padding: 0;
}
.pub-nav .navbar-brand { color: #fff !important; font-weight: 800; }
.pub-nav .nav-link     { color: rgba(255,255,255,.75) !important; }
.pub-nav .nav-link:hover { color: #fff !important; }
.pub-section { padding: 64px 0; }
.pub-section.alt { background: #f8faf9; }

/* ── Cert preview ─────────────────────────────────────────────────────────── */
.cert-page {
  background: #fff;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}
.certificate {
  width: 100%;
  max-width: 800px;
  border: 8px solid var(--teal);
  border-radius: 4px;
  padding: 48px 56px;
  position: relative;
  font-family: 'Manrope', serif;
  text-align: center;
  box-shadow: 0 4px 32px rgba(0,0,0,.12);
}
.certificate::before {
  content: '';
  position: absolute;
  inset: 12px;
  border: 2px solid var(--gold);
  border-radius: 2px;
  pointer-events: none;
}
.cert-header { color: var(--teal-dark); }
.cert-org    { font-size: .75rem; text-transform: uppercase; letter-spacing: 2px; color: #666; }
.cert-title  { font-size: 2rem; font-weight: 800; color: var(--teal); margin: 8px 0; }
.cert-body   { font-size: 1rem; color: #333; margin: 16px 0; line-height: 1.7; }
.cert-name   { font-size: 1.7rem; font-weight: 800; color: var(--teal-dark); margin: 12px 0; }
.cert-footer { margin-top: 40px; display: flex; justify-content: space-between; }
.cert-sig    { text-align: center; }
.cert-sig-line { border-top: 1px solid #333; width: 160px; margin: 0 auto 4px; }
.cert-vid    { font-size: .72rem; color: #888; margin-top: 24px; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .page-body { padding: 16px; }
  .pub-hero h1 { font-size: 1.6rem; }
}

/* ── Utilities ────────────────────────────────────────────────────────────── */
.text-teal { color: var(--teal) !important; }
.text-gold { color: var(--gold) !important; }
.bg-teal   { background: var(--teal) !important; }
.bg-teal-light { background: var(--teal-light) !important; }
.fw-800    { font-weight: 800; }
.page-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--teal-dark);
  margin-bottom: 4px;
}
.page-subtitle { color: #6b7b74; font-size: .85rem; margin-bottom: 24px; }
.divider { border-color: #e0eae7; }

/* Chat */
.chat-box {
  height: 420px;
  overflow-y: auto;
  border: 1px solid #e0eae7;
  border-radius: var(--radius);
  background: #f8faf9;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-msg { display: flex; gap: 10px; }
.chat-msg.mine { flex-direction: row-reverse; }
.chat-msg .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff; font-size: .78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-msg .bubble {
  background: #fff;
  border: 1px solid #e0eae7;
  border-radius: 12px 12px 12px 2px;
  padding: 8px 12px;
  max-width: 75%;
  font-size: .85rem;
}
.chat-msg.mine .bubble {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
  border-radius: 12px 12px 2px 12px;
}
.chat-msg .meta { font-size: .67rem; color: #999; margin-top: 2px; }
.chat-msg.mine .meta { text-align: right; }

/* Progress level bar */
.level-bar { height: 8px; border-radius: 4px; background: #e0eae7; }
.level-fill { height: 100%; border-radius: 4px; background: var(--teal); transition: width .5s; }
