/* ============================================================
   Elegant Certificate — theme.css
   Brand layer on top of Pico CSS v2
   Chonburi (headings) + Sarabun (body) — no exceptions
   Brand palette: Navy #052859 | Maroon #9a1746 | Sand #fdf5e6
   ============================================================ */

/* Always render in light mode — never let OS dark-mode override */
html { color-scheme: light; }

/* ── Global page background: bright/light, never black ─────── */
body {
  background-color: #f0f0f0 !important;
  color: #1a1a2e !important;
}

/* ── Override Pico dark-mode variables for ALL themes ───────── */
:root,
:root[data-theme="light"],
:root[data-theme="dark"],
:root:not([data-theme]) {
  --pico-background-color:                #f0f0f0 !important;
  --pico-color:                           #1a1a2e !important;
  --pico-card-background-color:           #ffffff !important;
  --pico-card-border-color:               #e5e7eb !important;
  --pico-muted-color:                     #555555 !important;
  --pico-muted-border-color:              #dddddd !important;
  --pico-form-element-background-color:   #ffffff !important;
  --pico-form-element-selected-background-color: #f0f4ff !important;
  --pico-form-element-color:              #1a1a2e !important;
  --pico-form-element-placeholder-color:  #9ca3af !important;
  --pico-form-element-active-background-color: #ffffff !important;
  --pico-form-element-disabled-background-color: #f3f4f6 !important;
  --pico-form-element-disabled-color:     #9ca3af !important;
}

/* ── Force ALL form inputs to white/light — Pico dark vars won't win ── */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"])
    :not([type="submit"]):not([type="button"]):not([type="reset"]),
select,
textarea {
  background-color: #ffffff !important;
  color: #1a1a2e !important;
  border-color: #cccccc !important;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"])
    :not([type="submit"]):not([type="button"]):not([type="reset"])::placeholder,
textarea::placeholder {
  color: #9ca3af !important;
}

/* ── Checkboxes & radio — never stretch to full width ───────── */
input[type="checkbox"],
input[type="radio"] {
  width: auto !important;
  height: auto !important;
  min-width: 0 !important;
  display: inline-block !important;
  cursor: pointer !important;
  accent-color: #052859;
  flex-shrink: 0;
  pointer-events: auto !important;
  opacity: 1 !important;
  position: static !important;
}

/* Google Fonts are loaded in every layout shell */
@import url('https://fonts.googleapis.com/css2?family=Chonburi&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
  --font-brand: 'Chonburi', serif;
  --font-body:  'Sarabun', sans-serif;

  --pico-font-family:   var(--font-body);
  --pico-font-size:     16px;
  --pico-line-height:   1.6;

  /* Override Pico's default cyan-blue with brand navy */
  --pico-primary:        #052859;
  --pico-primary-hover:  #083a80;
  --pico-primary-focus:  rgba(5, 40, 89, 0.25);
  --pico-color:          #1a1a2e;
  --pico-background-color: #ffffff;
  --pico-card-background-color: #ffffff;
  --pico-form-element-border-color: #cccccc;
  --pico-form-element-active-border-color: #052859;
  --pico-form-element-focus-color: rgba(5, 40, 89, 0.2);

  --brand-navy:         #052859;
  --brand-navy-hover:   #083a80;
  --brand-maroon:       #9a1746;   /* hover/active accent from old system */
  --brand-maroon-hover: #7a1238;
  --brand-gold:         #c9a14b;
  --brand-gold-hover:   #b8903d;
  --brand-sand:         #fdf5e6;   /* w3-sand: old system header bg */

  --color-day1:         #7C3AED;
  --color-day1-hover:   #6d28d9;
  --color-day2:         #EF4444;
  --color-day2-hover:   #dc2626;

  --color-success:      #16a34a;
  --color-warning:      #ca8a04;
  --color-danger:       #dc2626;

  --sidebar-width:      240px;
}

/* ── Typography ────────────────────────────────────────────── */
.brand-logo,
.brand-title,
h1, h2 {
  font-family: var(--font-brand);
}

body, p, input, select, textarea,
table, th, td, label, button,
.admin-table {
  font-family: var(--font-body);
}

/* ── Admin layout ───────────────────────────────────────────── */
body.layout-admin {
  --pico-font-size: 14px;
}

/* ── Global links — brand navy, never browser-default blue ──── */
a {
  color: var(--brand-navy);
  text-decoration: none;
}
a:hover {
  color: var(--brand-maroon);
  text-decoration: underline;
}

/* ── Navigation — sand bg matching old system header ────────── */
nav.site-nav {
  background: var(--brand-sand);          /* #fdf5e6 warm cream */
  border-bottom: 3px solid var(--brand-navy);
  color: var(--brand-navy);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

nav.site-nav a {
  color: var(--brand-navy);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

nav.site-nav a:hover,
nav.site-nav a.active {
  background: var(--brand-navy);
  color: #fff;
  text-decoration: none;
}

nav.site-nav .brand {
  font-family: var(--font-brand);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brand-navy);
  margin-right: auto;
  text-decoration: none;
}

nav.site-nav .camp-badge {
  background: rgba(5, 40, 89, 0.1);
  border-radius: 20px;
  padding: 0.2rem 0.75rem;
  font-size: 0.8rem;
  color: var(--brand-navy);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn-day1 {
  background: var(--color-day1);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.875rem;
}
.btn-day1:hover { background: var(--color-day1-hover); }

.btn-day2 {
  background: var(--color-day2);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.875rem;
}
.btn-day2:hover { background: var(--color-day2-hover); }

.btn-primary {
  background: var(--brand-navy);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--brand-maroon); }

.btn-gold {
  background: var(--brand-gold);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  font-family: var(--font-body);
  transition: background 0.15s;
}
.btn-gold:hover { background: var(--brand-gold-hover); }

/* ── Old-system form card style ─────────────────────────────── */
.form-card {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 20px;
  background-color: #f8f8f8;
  border-radius: 8px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.form-card .form-title {
  color: var(--brand-navy);
  font-family: var(--font-brand);
  font-weight: normal;
  text-decoration: underline;
  text-decoration-thickness: 3px;
  text-decoration-color: var(--brand-navy);
  margin-bottom: 20px;
}
.form-card label.field-label {
  display: block;
  font-size: 14px;
  color: #888;
  margin-top: 4px;
}
.form-card input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.form-card select,
.form-card textarea {
  width: 100%;
  padding: 11px 12px;
  margin-top: 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 15px;
  background: #ffffff !important;
  color: #1a1a2e !important;
  box-sizing: border-box;
}
.form-card input:not([type="checkbox"]):not([type="radio"]):focus,
.form-card select:focus,
.form-card textarea:focus {
  border-color: var(--brand-navy);
  outline: none;
  box-shadow: 0 0 0 2px rgba(5,40,89,0.15);
}
.form-card input.readonly-bg,
.form-card select.readonly-bg { background-color: #ffcccc !important; }

/* Checkboxes inside form-card must NOT be full-width */
.form-card input[type="checkbox"],
.form-card input[type="radio"] {
  width: auto !important;
  height: auto !important;
  padding: 0 !important;
  margin-top: 0 !important;
  display: inline-block !important;
  cursor: pointer !important;
  accent-color: #052859;
}
.form-card .btn-submit {
  display: block;
  width: 100%;
  background-color: var(--brand-navy);
  color: #fff;
  padding: 13px 20px;
  font-size: 18px;
  font-family: var(--font-body);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}
.form-card .btn-submit:hover { background-color: var(--brand-maroon); }
.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.form-row .field {
  flex: 1;
  min-width: 160px;
}
.form-row .field-sm { flex: 0 0 160px; }
.field-group { margin-top: 10px; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge-done {
  color: var(--color-success);
  font-weight: 700;
  font-size: 0.875rem;
}

.badge-status {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-grey   { background: #e5e7eb; color: #374151; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-dim    { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }

/* ── CRM status colors ──────────────────────────────────────── */
.status-ยังไม่ติดต่อ { background: #e5e7eb; color: #374151; }
.status-รอติดตามผล  { background: #fef3c7; color: #92400e; }
.status-สนใจสมัคร   { background: #dbeafe; color: #1e40af; }
.status-สมัครแล้ว   { background: #dcfce7; color: #15803d; font-weight: 700; }
.status-ปฏิเสธ      { background: #fee2e2; color: #991b1b; }
.status-ลบข้อมูล    { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }

/* ── Admin table ────────────────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.admin-table th {
  background: var(--pico-primary);
  color: #fff;
  padding: 0.55rem 0.75rem;
  text-align: left;
  font-weight: 600;
}
.admin-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}
.admin-table tr:hover td { background: #f9fafb; }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 520px;
  width: 94vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 32px rgba(0,0,0,0.25);
  position: relative;
}
.modal-header {
  background: var(--pico-primary);
  color: #fff;
  padding: 1rem 1.25rem;
  border-radius: 12px 12px 0 0;
  margin: -1.5rem -1.5rem 1.25rem -1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 { margin: 0; font-family: var(--font-brand); color: #fff; }
.modal-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0 0.25rem;
}

/* ── Step UI (Day 2 modal) ──────────────────────────────────── */
.step { display: flex; gap: 0.75rem; align-items: flex-start; margin: 0.75rem 0 1rem; }
.step-num {
  flex: 0 0 32px; height: 32px; border-radius: 50%;
  background: var(--color-day2); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.875rem;
}
.step-body { flex: 1; }
.step-title { font-weight: 700; margin-bottom: 0.35rem; }

/* ── Tinder Gallery ─────────────────────────────────────────── */
#gallery-root {
  position: fixed;
  inset: 0;
  background: #000;
  overflow: hidden;
  user-select: none;
}

.gallery-card {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}
.gallery-card.active { display: flex; }

.gallery-card__bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.gallery-card__overlay {
  position: relative;
  z-index: 2;
  width: 100%;
  padding: 1.25rem 1.25rem 1.5rem;
  background: linear-gradient(to top, rgba(0,0,0,0.78) 0%, rgba(0,0,0,0.0) 100%);
  color: #fff;
}

.gallery-card__overlay .nickname {
  font-family: var(--font-brand);
  font-size: 1.5rem;
  line-height: 1.2;
}
.gallery-card__overlay .school {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-top: 0.2rem;
}
.gallery-social {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.gallery-social a {
  display: inline-block;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(4px);
  border-radius: 20px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  color: #fff;
  text-decoration: none;
}

/* Day 2 gallery */
#gallery-root.day2 {
  background: #052859;
}
#gallery-root.day2 .gallery-card__center {
  position: relative;
  z-index: 2;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem 0;
}
#gallery-root.day2 .gallery-card__center img {
  max-width: 60vw;
  max-height: 55vh;
  border-radius: 16px;
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.gallery-card__note-box {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
  border-radius: 14px 14px 0 0;
  padding: 1rem 1.25rem;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}
.gallery-card__note-box .impression {
  font-size: 0.95rem;
  color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 0.4rem;
}

/* HUD counter */
#gallery-hud {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: rgba(0,0,0,0.5);
  color: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.875rem;
  z-index: 100;
}

/* Toast notification */
#gallery-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(5,40,89,0.9);
  color: #fff;
  padding: 0.5rem 1.25rem;
  border-radius: 24px;
  font-size: 0.875rem;
  z-index: 200;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
#gallery-toast.show { opacity: 1; }

/* ── Misc helpers ────────────────────────────────────────────── */
.text-muted   { color: #6b7280; font-size: 0.875rem; }
.text-success { color: var(--color-success); }
.text-danger  { color: var(--color-danger); }
.text-warning { color: var(--color-warning); }

.char-counter.ok     { color: var(--color-success); }
.char-counter.warn   { color: var(--color-warning); }
.char-counter.danger { color: var(--color-danger); }

.w-full { width: 100%; }
.mt-1  { margin-top: 0.25rem; }
.mt-2  { margin-top: 0.5rem; }
.mt-3  { margin-top: 0.75rem; }
.mb-3  { margin-bottom: 0.75rem; }
.gap-2 { gap: 0.5rem; }
.flex  { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 1rem; }

/* ── Privilege badge ─────────────────────────────────────────── */
#privilege-badge {
  display: none;
  padding: 0.5rem 0.9rem;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 8px;
  color: #15803d;
  font-size: 0.875rem;
  margin-top: 0.5rem;
}
