/* ============================================================
   SILAPA – ระบบบันทึกผลการแข่งขันศิลปหัตถกรรม
   Custom CSS  |  Bootstrap 5 + Sidebar Layout
   ============================================================ */

/* ── Typography ────────────────────────────────────────────── */
body, .table, .form-control, .form-select, .btn, .card, .modal, input, select, textarea {
  font-family: 'Sarabun', sans-serif;
}
h1,h2,h3,h4,h5,h6,.fw-bold,.card-header,th,.navbar-brand {
  font-family: 'Kanit', sans-serif;
}

/* ── Layout ─────────────────────────────────────────────────── */
#wrapper {
  min-height: calc(100vh - 56px);
}

#sidebar {
  width: 256px;
  min-height: 100%;
  transition: width .25s ease, transform .25s ease;
  flex-shrink: 0;
  overflow-x: hidden;
}
#sidebar.collapsed {
  width: 0;
}
#page-content {
  flex: 1;
  background: #f4f6f9;
  min-width: 0;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
#sidebar .nav-link {
  color: #cfd8dc;
  white-space: nowrap;
  border-radius: .375rem;
  margin-bottom: 2px;
  font-size: .875rem;
  padding: .45rem .75rem;
}
#sidebar .nav-link:hover, #sidebar .nav-link.active {
  background: rgba(255,255,255,.12);
  color: #fff;
}
#sidebar .nav-link.active { font-weight: 600; }
#sidebar .sidebar-section {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #78909c;
  padding: .6rem 1rem .2rem;
  list-style: none;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  border-radius: .75rem;
  border: none;
  box-shadow: 0 1px 6px rgba(0,0,0,.08);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  border-radius: .75rem .75rem 0 0 !important;
  font-size: .95rem;
}
.stat-card {
  border-radius: .75rem;
  border: none;
  box-shadow: 0 2px 12px rgba(0,0,0,.1);
  transition: transform .15s ease;
}
.stat-card:hover { transform: translateY(-2px); }

/* ── Tables ──────────────────────────────────────────────────── */
.table thead th {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #6c757d;
  white-space: nowrap;
  border-top: none;
}
.table-hover tbody tr:hover { background-color: rgba(13,110,253,.04); }

/* ── Award Badges ────────────────────────────────────────────── */
.badge-gold   { background: #ffc107; color: #000 !important; }
.badge-silver { background: #adb5bd; color: #fff !important; }
.badge-bronze { background: #cd7f32; color: #fff !important; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-control, .form-select, input[type="text"], input[type="email"],
input[type="password"], input[type="number"], input[type="search"],
input[type="tel"], input[type="url"], input[type="date"],
input[type="time"], textarea, select {
  color: #000 !important;
  background-color: #fff !important;
  box-shadow: none !important;
  -webkit-box-shadow: none !important;
}
.form-control:focus, .form-select:focus,
input[type="text"]:focus, input[type="email"]:focus,
input[type="password"]:focus, input[type="number"]:focus,
input[type="search"]:focus, input[type="tel"]:focus,
input[type="url"]:focus, input[type="date"]:focus,
input[type="time"]:focus, textarea:focus, select:focus {
  color: #000 !important;
  background-color: #fff !important;
  border-color: #1565c0;
  box-shadow: none !important;
  -webkit-box-shadow: none !important;
  outline: none;
}
.form-label { font-weight: 600; font-size: .875rem; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn { font-family: 'Sarabun', sans-serif; }

/* ── Page title area ─────────────────────────────────────────── */
.page-title { font-size: 1.2rem; font-weight: 600; }
.page-subtitle { color: #6c757d; font-size: .85rem; }

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  #sidebar, .navbar, .btn, .no-print, .toast-container { display: none !important; }
  #page-content { padding: 0 !important; background: #fff !important; }
  .card { border: 1px solid #dee2e6 !important; box-shadow: none !important; }
  body { font-size: 11pt; }
}

/* ── Certificate ─────────────────────────────────────────────── */
.cert-page {
  width: 297mm;
  min-height: 210mm;
  background: #fffdf0;
  position: relative;
  page-break-after: always;
  box-sizing: border-box;
  padding: 12mm 14mm;
  margin: 0 auto 20px;
}
.cert-outer-border {
  position: absolute;
  inset: 6mm;
  border: 3px double #8B0000;
  pointer-events: none;
}
.cert-inner-border {
  position: absolute;
  inset: 9mm;
  border: 1.5px solid #8B0000;
  pointer-events: none;
}
.cert-content {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  padding: 4mm 12mm;
}
.cert-title {
  font-family: 'Kanit', sans-serif;
  font-size: 32pt;
  font-weight: 700;
  color: #8B0000;
  letter-spacing: .05em;
  line-height: 1.1;
}
.cert-subtitle {
  font-size: 13pt;
  color: #555;
  font-family: 'Sarabun', sans-serif;
}
.cert-recipient {
  font-family: 'Kanit', sans-serif;
  font-size: 20pt;
  font-weight: 600;
  color: #1a237e;
  border-bottom: 2px dotted #8B0000;
  padding-bottom: 2mm;
  min-width: 200mm;
}
.cert-school {
  font-size: 13pt;
  color: #333;
  font-family: 'Sarabun', sans-serif;
}
.cert-body {
  font-size: 13pt;
  color: #222;
  line-height: 1.7;
}
.cert-award {
  font-family: 'Kanit', sans-serif;
  font-size: 16pt;
  font-weight: 700;
  color: #8B0000;
}
.cert-event {
  font-size: 12pt;
  color: #444;
}
.cert-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  gap: 30mm;
  align-items: flex-end;
}
.cert-signer {
  text-align: center;
  font-size: 11pt;
}
.cert-signer .line {
  border-top: 1.5px solid #333;
  width: 60mm;
  margin: 0 auto 2mm;
}
.cert-signer .name {
  font-family: 'Kanit', sans-serif;
  font-weight: 600;
}

@media print {
  @page { size: A4 landscape; margin: 0; }
  .cert-page { margin: 0; box-shadow: none; }
  .no-print-wrap { display: none !important; }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { position: fixed; z-index: 1045; height: 100%; left: 0; top: 56px; }
  #sidebar.collapsed { transform: translateX(-100%); }
  #page-content { width: 100%; }
  .cert-page { width: 100%; min-height: auto; }
}
