@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ─────────────────────────────────────────────────────────── */
:root {
  --nu-blue: #1a237e;
  --nu-blue-mid: #283593;
  --nu-blue-light: #3949ab;
  --nu-gold: #f9a825;
  --nu-gold-light: #fdd835;
  --bg-dark: #0d1331;
  --bg-card: rgba(255, 255, 255, 0.06);
  --bg-card-solid: #ffffff;
  --text-primary: #1a1a2e;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.15);
  --transition: all 0.25s ease;
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Sarabun', 'Inter', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: #f0f2f9;
  min-height: 100vh;
}

/* ── Hero Background (Landing, Consent, Form ─ Light Theme) ────────────── */
.hero-layout {
  min-height: 100vh;
  background: #f0f4ff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.hero-layout::before {
  display: none;
}

/* ── White Card (public pages) ────────────────────────────────── */
.glass-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 4px 32px rgba(26, 35, 126, 0.10);
  animation: slideUp 0.5s ease;
}

.glass-card.wide {
  max-width: 680px;
}

.glass-card.xl {
  max-width: 800px;
}

/* ── Logo & Branding ────────────────────────────────────────────────────────── */
.nu-logo-wrap {
  text-align: center;
  margin-bottom: 28px;
}

.nu-logo-wrap img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-bottom: 12px;
}

.nu-logo-wrap .app-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--nu-blue);
  letter-spacing: -0.3px;
}

.nu-logo-wrap .app-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: var(--transition);
  outline: none;
  white-space: nowrap;
}

.btn:focus-visible {
  outline: 3px solid var(--nu-gold);
  outline-offset: 2px;
}

.btn-thaid {
  background: linear-gradient(135deg, #4caf50, #2e7d32);
  color: #fff;
  width: 100%;
  padding: 14px;
  font-size: 16px;
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.35);
}

.btn-thaid:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(76, 175, 80, 0.45);
}

.btn-primary {
  background: linear-gradient(135deg, var(--nu-blue-light), var(--nu-blue));
  color: #fff;
  box-shadow: 0 4px 15px rgba(26, 35, 126, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(26, 35, 126, 0.4);
}

.btn-ms {
  background: #fff;
  color: #333;
  border: 1px solid #ddd;
  width: 100%;
  padding: 13px;
  font-size: 15px;
}

.btn-ms:hover {
  background: #f5f5f5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--nu-blue-light);
  color: var(--nu-blue);
}

.btn-outline:hover {
  background: #eff2ff;
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
  border-radius: 6px;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 17px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

/* ── Form Elements ──────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #374151;
}

.form-label.dark {
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid #9ca3af;
  background: #ffffff;
  color: #111827;
  font-family: inherit;
  font-size: 15px;
  transition: var(--transition);
  outline: none;
}

.form-control::placeholder {
  color: #9ca3af;
}

.form-control:focus {
  border-color: var(--nu-blue-light);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(57, 73, 171, 0.15);
}

.form-control.readonly,
.form-control[readonly] {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #6b7280;
  cursor: not-allowed;
}

/* Solid form variant (admin pages on white background) */
.form-control.solid {
  background: #fff;
  border-color: var(--border-color);
  color: var(--text-primary);
}

.form-control.solid::placeholder {
  color: #aaa;
}

.form-control.solid:focus {
  border-color: var(--nu-blue-light);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(57, 73, 171, 0.15);
}

.form-hint {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}

.form-hint.dark {
  color: var(--text-muted);
}

.required-mark {
  color: var(--nu-blue);
  margin-left: 2px;
}

/* ── Checkbox ──────────────────────────────────────────────────────────────── */
.checkbox-wrap {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: var(--radius-sm);
  padding: 16px;
  cursor: pointer;
  transition: var(--transition);
}

.checkbox-wrap:hover {
  background: #f3f4f6;
  border-color: #c7d2fe;
}

.checkbox-wrap input[type="checkbox"],
.checkbox-wrap input[type="radio"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  accent-color: var(--nu-blue);
  cursor: pointer;
  margin-top: 2px;
}

.checkbox-wrap label {
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  line-height: 1.5;
}

/* ── Divider ──────────────────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: #9ca3af;
  font-size: 13px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

/* ── Alert / Info Boxes ─────────────────────────────────────────────────────── */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.alert-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #7f1d1d;
}

/* Solid alerts for light backgrounds */
.alert.solid-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.alert.solid-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.alert.solid-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.alert.solid-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #7f1d1d;
}

/* ── Badge ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-info {
  background: #dbeafe;
  color: #1e40af;
}

.badge-success {
  background: #d1fae5;
  color: #065f46;
}

/* ── Admin Layout ─────────────────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: 100vh;
  background: #f0f2f9;
}

.admin-sidebar {
  width: 260px;
  min-width: 260px;
  background: linear-gradient(180deg, var(--bg-dark) 0%, var(--nu-blue) 100%);
  padding: 0;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 15px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.sidebar-brand .brand-title {
  font-size: 14px;
  font-weight: 700;
  color: #fff;
}

.sidebar-brand .brand-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.55);
  margin-top: 3px;
}

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-left-color: var(--nu-gold);
}

.sidebar-nav a .nav-icon {
  font-size: 18px;
  min-width: 22px;
}

.sidebar-user {
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px;
}

.sidebar-user .user-name {
  color: #fff;
  font-weight: 600;
}

.sidebar-user .user-email {
  color: rgba(255, 255, 255, 0.55);
  font-size: 12px;
}

.sidebar-user a {
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  font-size: 12px;
}

.sidebar-user a:hover {
  color: var(--nu-gold);
}

.admin-main {
  flex: 1;
  overflow: auto;
}

.admin-topbar {
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.admin-content {
  padding: 28px;
}

/* ── Cards (Admin) ─────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.card-body {
  padding: 24px;
}

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

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

thead th {
  background: #f8fafc;
  padding: 12px 14px;
  text-align: left;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #f3f4f6;
  transition: var(--transition);
}

tbody tr:hover {
  background: #f8fafc;
}

tbody td {
  padding: 13px 14px;
  vertical-align: middle;
  color: var(--text-primary);
}

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

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.stat-icon.blue {
  background: #eff6ff;
}

.stat-icon.amber {
  background: #fffbeb;
}

.stat-icon.teal {
  background: #f0fdf4;
}

.stat-icon.purple {
  background: #faf5ff;
}

.stat-info .stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-info .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Filter Tabs ───────────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-tab {
  padding: 8px 18px;
  border-radius: 25px;
  border: 1.5px solid var(--border-color);
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.filter-tab:hover {
  border-color: var(--nu-blue-light);
  color: var(--nu-blue);
}

.filter-tab.active {
  background: var(--nu-blue);
  border-color: var(--nu-blue);
  color: #fff;
}

/* ── Modal ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s ease;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h4 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--danger);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Textarea ──────────────────────────────────────────────────────────────── */
textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

textarea.form-control.solid {
  resize: vertical;
  min-height: 140px;
  color: var(--text-primary);
}

/* ── Detail Grid ───────────────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-item .detail-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.detail-item .detail-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-all;
}

/* ── Audit Log ─────────────────────────────────────────────────────────────── */
.audit-entry {
  padding: 12px 0;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.audit-entry:last-child {
  border-bottom: none;
}

.audit-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--nu-blue-light);
  margin-top: 5px;
  flex-shrink: 0;
}

.audit-entry .audit-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── PDPA Scroll Box ───────────────────────────────────────────────────────── */
.pdpa-box {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-sm);
  padding: 20px;
  max-height: 280px;
  overflow-y: auto;
  font-size: 13px;
  color: #374151;
  line-height: 1.8;
  scrollbar-width: thin;
  scrollbar-color: #d1d5db transparent;
  margin-bottom: 20px;
}

.pdpa-box h4 {
  color: var(--nu-blue);
  font-size: 15px;
  margin-bottom: 10px;
}

.pdpa-box p {
  margin-bottom: 10px;
}

/* ── Step Indicator ────────────────────────────────────────────────────────── */
.step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
  gap: 0;
}

.step {
  display: flex;
  align-items: center;
  gap: 8px;
}

.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  border: 2px solid #d1d5db;
  color: #9ca3af;
  background: #fff;
}

.step.done .step-circle {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.step.active .step-circle {
  background: var(--nu-blue);
  border-color: var(--nu-blue);
  color: #fff;
}

.step-label {
  font-size: 12px;
  color: #6b7280;
}

.step.done .step-label,
.step.active .step-label {
  color: var(--nu-blue);
  font-weight: 600;
}

.step-line {
  flex: 1;
  height: 2px;
  background: #e5e7eb;
  margin: 0 8px;
  min-width: 30px;
}

.step-line.done {
  background: var(--success);
}

/* ── Animations ────────────────────────────────────────────────────────────── */
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ── Success Page ──────────────────────────────────────────────────────────── */
.success-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--success), #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4);
  animation: slideUp 0.5s ease 0.2s both;
}

/* ── Utilities ─────────────────────────────────────────────────────────────── */
.text-center {
  text-align: center;
}

.text-white {
  color: var(--nu-blue);
}

.text-muted {
  color: #6b7280;
}

.text-sm {
  font-size: 13px;
}

.text-xs {
  font-size: 12px;
}

.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.mt-4 {
  margin-top: 4px;
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-20 {
  margin-top: 20px;
}

.mt-24 {
  margin-top: 24px;
}

.mb-0 {
  margin-bottom: 0;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-20 {
  margin-bottom: 20px;
}

.fw-600 {
  font-weight: 600;
}

.fw-700 {
  font-weight: 700;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .glass-card {
    padding: 28px 20px;
  }

  .admin-sidebar {
    display: none;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .admin-content {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .filter-tabs {
    flex-direction: column;
  }
}