/* CertHub — Global Stylesheet */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #6366f1;
  --primary-dk: #4f46e5;
  --primary-lt: #ede9fe;
  --gold:       #f59e0b;
  --green:      #22c55e;
  --red:        #ef4444;
  --bg:         #f0f4f8;
  --surface:    #ffffff;
  --border:     #e2e8f0;
  --text:       #1a202c;
  --muted:      #64748b;
  --radius:     12px;
  --shadow:     0 2px 12px rgba(0,0,0,.07);
}

body {
  font-family: 'Segoe UI', 'Noto Sans Thai', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

/* ===================== LAYOUT ===================== */
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px; min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 100;
}
.sidebar-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .school { font-size: 11px; color: var(--muted); }
.sidebar-brand .app-name { font-size: 17px; font-weight: 800; color: var(--primary); margin-top: 2px; }

.nav-group { padding: 12px 10px; }
.nav-label {
  font-size: 10px; font-weight: 700; color: #94a3b8;
  letter-spacing: .8px; text-transform: uppercase;
  padding: 0 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  font-size: 13px; color: var(--muted);
  text-decoration: none; transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-lt); color: var(--primary); font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-divider { height: 1px; background: var(--border); margin: 6px 10px; }

.sidebar-footer {
  margin-top: auto; padding: 14px;
  border-top: 1px solid var(--border);
}
.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 9px;
  background: var(--bg);
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.user-info .uname { font-size: 12px; font-weight: 700; }
.user-info .urole { font-size: 10px; color: var(--muted); }
.sidebar-footer a { font-size: 11px; color: var(--muted); text-decoration: none; display: block; margin-top: 6px; padding-left: 10px; }
.sidebar-footer a:hover { color: var(--red); }

/* Main content */
.main { flex: 1; margin-left: 220px; display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 14px 28px; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 16px; font-weight: 700; }
.breadcrumb { font-size: 11px; color: var(--muted); margin-top: 2px; }

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

/* ===================== CARDS ===================== */
.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.card-header { padding: 18px 22px 0; }
.card-body { padding: 20px 22px 22px; }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px;
  font-size: 13px; font-weight: 700; cursor: pointer; border: none;
  text-decoration: none; transition: background .12s, opacity .12s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline  { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-ghost    { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-danger   { background: #fee2e2; color: var(--red); }
.btn-warning  { background: #fef9c3; color: #92400e; }
.btn-success  { background: #dcfce7; color: #166534; }
.btn-sm { padding: 5px 10px; font-size: 11px; border-radius: 6px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ===================== FORMS ===================== */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 700; color: #475569; }
.form-hint { font-size: 10px; color: var(--muted); }

input[type=text], input[type=password], input[type=email],
input[type=date], input[type=search], select, textarea {
  padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 13px; outline: none;
  background: var(--surface); color: var(--text); font-family: inherit;
  transition: border-color .12s;
  width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 70px; }

.upload-zone {
  border: 2.5px dashed #c4b5fd; border-radius: 14px;
  padding: 40px 24px; text-align: center; cursor: pointer;
  background: #faf5ff; transition: border-color .15s, background .15s;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--primary); background: var(--primary-lt);
}
.upload-zone .uz-icon { font-size: 42px; margin-bottom: 10px; }
.upload-zone h3 { font-size: 15px; font-weight: 700; color: #4c1d95; margin-bottom: 4px; }
.upload-zone p { font-size: 12px; color: #7c3aed; }
.upload-zone small { font-size: 10px; color: var(--muted); display: block; margin-top: 8px; }

/* ===================== TABLES ===================== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: 10px 14px; font-size: 10px; font-weight: 700;
  text-align: left; background: var(--bg);
  color: var(--muted); letter-spacing: .5px; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #faf5ff; }

/* ===================== BADGES ===================== */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px;
  font-size: 10px; font-weight: 700; white-space: nowrap;
}
.badge-national     { background: #fef9c3; color: #854d0e; }
.badge-province     { background: #dbeafe; color: #1e40af; }
.badge-region       { background: #ffe4e6; color: #9f1239; }
.badge-district     { background: #dcfce7; color: #166534; }
.badge-school       { background: #f3e8ff; color: #6b21a8; }
.badge-international{ background: #fce7f3; color: #9d174d; }
.badge-admin    { background: #fef9c3; color: #854d0e; }
.badge-teacher  { background: var(--primary-lt); color: var(--primary); }

/* ===================== STATS ===================== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
}
.stat-card .num { font-size: 32px; font-weight: 800; color: var(--primary); }
.stat-card .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ===================== ALERTS ===================== */
.alert { padding: 11px 15px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-error   { background: #fee2e2; border: 1.5px solid #fecaca; color: #dc2626; }
.alert-success { background: #dcfce7; border: 1.5px solid #86efac; color: #166534; }
.alert-info    { background: #eff6ff; border: 1.5px solid #bfdbfe; color: #1d4ed8; }
.alert-warn    { background: #fffbeb; border: 1.5px solid #fde68a; color: #92400e; }

/* ===================== SEARCH BAR ===================== */
.search-bar {
  position: relative; max-width: 380px;
}
.search-bar input { padding-left: 36px; }
.search-bar .icon {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%); color: var(--muted); pointer-events: none;
}

/* ===================== TABS ===================== */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  padding: 6px 14px; border-radius: 99px; font-size: 12px; font-weight: 700;
  cursor: pointer; border: 1.5px solid var(--border);
  color: var(--muted); background: transparent; transition: all .12s;
}
.tab.active { background: var(--primary-lt); border-color: #c4b5fd; color: var(--primary); }
.tab:hover:not(.active) { background: var(--bg); }

/* ===================== EMPTY STATE ===================== */
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h3 { font-size: 15px; font-weight: 700; margin-bottom: 6px; }

/* ===================== MISC ===================== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.text-muted { color: var(--muted); font-size: 12px; }
.text-sm { font-size: 12px; }
.fw-bold { font-weight: 700; }
.text-primary { color: var(--primary); }

/* Confidence colors */
.conf-high { color: #16a34a; }
.conf-med  { color: #d97706; }
.conf-low  { color: #dc2626; }

/* Name input in review */
.name-input-review {
  border: 1.5px solid var(--border); border-radius: 6px;
  padding: 6px 9px; font-size: 13px; font-weight: 600;
  width: 100%; background: var(--surface); color: var(--text);
  outline: none; transition: border-color .12s;
}
.name-input-review:focus { border-color: var(--primary); }
.name-input-review.ok   { border-color: #86efac; background: #f0fdf4; }
.name-input-review.warn { border-color: #fde68a; background: #fffbeb; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Print */
@media print {
  .sidebar, .topbar, .btn { display: none !important; }
  .main { margin-left: 0; }
}
