/* VIVAJOY PLANET Booking — โทนสีเดียวกับ PR (#1e1b4b / #6c5ce7) ไม่พึ่ง CDN */
:root {
  --navy: #1e1b4b;
  --primary: #6c5ce7;
  --primary-dark: #4f46e5;
  --bg: #f4f6f9;
  --card: #fff;
  --text: #333;
  --muted: #6b7280;
  --line: #e5e7eb;
  --success: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Sarabun", "TH Sarabun New", "Leelawadee UI", "Segoe UI", Tahoma, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.6;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.main { flex: 1; padding-top: 24px; padding-bottom: 40px; }

/* ---------- topbar ---------- */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 50; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 60px; flex-wrap: wrap; }
.brand { color: #fff; font-size: 20px; font-weight: 700; }
.brand span { color: #a29bfe; }
.brand:hover { text-decoration: none; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav a { color: rgba(255,255,255,.85); padding: 8px 12px; border-radius: 6px; }
.nav a:hover, .nav a.active { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.nav-user { color: rgba(255,255,255,.6); font-size: 13px; padding: 0 8px; }
.nav-logout { display: inline; }
.nav-logout button {
  background: var(--danger); color: #fff; border: 0; border-radius: 6px;
  padding: 7px 14px; font: inherit; font-size: 14px; cursor: pointer;
}
.nav-toggle { display: none; }
.nav-burger { display: none; cursor: pointer; padding: 10px; }
.nav-burger span { display: block; width: 22px; height: 2px; background: #fff; margin: 4px 0; }

@media (max-width: 820px) {
  .nav-burger { display: block; }
  .nav { display: none; width: 100%; flex-direction: column; align-items: stretch; padding: 8px 0 14px; }
  .nav-toggle:checked ~ .nav { display: flex; }
  .nav a { padding: 10px 12px; }
  .nav-user { padding: 8px 12px; }
  .nav-logout button { width: 100%; margin-top: 6px; }
}

/* ---------- card / layout ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 20px; margin-bottom: 20px; }
.card-narrow { max-width: 460px; margin-left: auto; margin-right: auto; }
.card h1, .card h2 { color: var(--navy); margin-bottom: 14px; }
h1 { font-size: 24px; } h2 { font-size: 20px; } h3 { font-size: 17px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { color: var(--navy); }
.muted { color: var(--muted); font-size: 14px; }
.text-center { text-align: center; }
.mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; }

.grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 20px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.08); border-left: 4px solid var(--primary); }
.stat .num { font-size: 26px; font-weight: 700; color: var(--navy); }
.stat .lbl { color: var(--muted); font-size: 13px; }

/* ---------- form ---------- */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-weight: 600; margin-bottom: 4px; color: var(--navy); }
.form-row .hint { color: var(--muted); font-size: 13px; margin-top: 3px; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px;
  font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,92,231,.15); }
textarea { min-height: 90px; resize: vertical; }
input[readonly] { background: #f3f4f6; color: var(--muted); }
.req { color: var(--danger); }
.form-row .field-error { color: var(--danger); font-size: 13px; margin-top: 3px; }

.btn {
  display: inline-block; padding: 9px 18px; border-radius: 8px; border: 0; cursor: pointer;
  font: inherit; font-weight: 600; text-align: center; background: #e5e7eb; color: var(--text);
}
.btn:hover { text-decoration: none; filter: brightness(.95); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warn); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- alert / badge ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warn    { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-info    { background: #eef2ff; color: #3730a3; border-color: #c7d2fe; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-confirmed { background: #d1fae5; color: #065f46; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-completed { background: #e0e7ff; color: #3730a3; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { background: #f9fafb; color: #555; font-size: 13px; white-space: nowrap; }
.table tr:hover td { background: #fafafe; }

/* ---------- หน้าแรก (hero + ขั้นตอน) ---------- */
.hero {
  border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; color: #fff;
  background: linear-gradient(100deg, rgba(30,27,75,.92) 0%, rgba(30,27,75,.7) 55%, rgba(30,27,75,.25) 100%),
              url('/main.jpg') center / cover no-repeat, var(--navy);
}
.hero-text { padding: 44px 36px; max-width: 640px; }
.hero h1 { font-size: 30px; line-height: 1.3; margin-bottom: 12px; }
.hero p { font-size: 16px; opacity: .95; }
.hero .btn { border-color: #fff; }
.hero-note { margin-top: 14px; font-size: 14px !important; }
.hero-note a { color: #fff; text-decoration: underline; }
.btn-lg { padding: 11px 26px; font-size: 16px; }
.steps { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.step { margin-bottom: 0; }
.step h3 { color: var(--navy); margin: 8px 0 4px; }
.step-no {
  width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
@media (max-width: 640px) {
  .hero-text { padding: 28px 20px; }
  .hero h1 { font-size: 24px; }
}

/* ---------- tour detail / booking ---------- */
.breadcrumb { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.tour-detail { display: grid; gap: 20px; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); align-items: start; }
.tour-cover { width: 100%; max-height: 420px; object-fit: cover; border-radius: 8px; margin-bottom: 16px; }
.tour-desc { white-space: normal; }
.info-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; }
.info-list dt { color: var(--muted); font-size: 14px; }
.info-list dd { font-weight: 600; word-break: break-word; }
.info-list-wide { max-width: 640px; }
.chip { display: inline-block; background: #eef2ff; color: #3730a3; border-radius: 999px; padding: 1px 10px; margin: 0 4px 4px 0; font-size: 13px; }
.slot-list { display: flex; flex-wrap: wrap; gap: 8px; }
.slot { position: relative; cursor: pointer; }
.slot input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.slot span { display: inline-block; padding: 8px 18px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; font-weight: 600; }
.slot input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.slot input:focus-visible + span { box-shadow: 0 0 0 3px rgba(108,92,231,.3); }
.input-time { max-width: 200px; }
.booking-no { font-family: Consolas, monospace; letter-spacing: .5px; margin-bottom: 0 !important; }
.pre-line { white-space: pre-line; font-weight: 400 !important; }
.btn-group form { display: inline; margin: 0; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.tabs a { padding: 6px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--text); font-size: 14px; }
.tabs a:hover { text-decoration: none; border-color: var(--primary); }
.tabs a.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.table-card { padding: 0; overflow: hidden; }
.table td.actions { white-space: nowrap; }
.pager { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.pager a { min-width: 36px; padding: 6px 10px; text-align: center; border-radius: 6px; background: #fff; border: 1px solid var(--line); }
.pager a.active { background: var(--primary); border-color: var(--primary); color: #fff; }

@media (max-width: 820px) {
  .tour-detail { grid-template-columns: 1fr; }
}
/* ตารางบนมือถือ: แสดงเป็นการ์ดทีละแถว */
@media (max-width: 640px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { border-bottom: 1px solid var(--line); padding: 10px 14px; }
  .table-stack td { border: 0; padding: 3px 0; }
  .table-stack td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 72px; color: var(--muted); font-size: 13px; }
  .table-stack td.actions { padding-top: 8px; }
  .info-list { grid-template-columns: 1fr; gap: 0; }
  .info-list dd { margin-bottom: 8px; }
}

/* ---------- footer ---------- */
.footer { background: #fff; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; padding: 16px 0; text-align: center; }

@media (max-width: 560px) {
  body { font-size: 14px; }
  .card { padding: 16px; }
  h1 { font-size: 21px; }
}

/* ---------- admin (Phase 5) ---------- */
.filter-bar { padding: 16px 20px 12px; }
.filter-grid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.filter-grid .form-row { margin-bottom: 10px; }
.pager-gap { padding: 6px 4px; color: var(--muted); }
.pager { margin-bottom: 20px; }
.admin-detail { display: grid; gap: 20px; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.action-list { display: flex; flex-direction: column; gap: 8px; }
.btn-outline { background: #fff; color: var(--text); border: 1px solid #d1d5db; }
.form-row label.check, label.check { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
label.check input { width: auto; }
details.card > summary { cursor: pointer; list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary h2 { display: inline; margin: 0; }
details.card > summary::after { content: ' ▾'; color: var(--muted); }
details.card[open] > summary { margin-bottom: 12px; }
a.stat { display: block; color: inherit; }
a.stat:hover { text-decoration: none; filter: brightness(.98); }
.stat-warn { border-left-color: var(--warn); }
.stat-success { border-left-color: var(--success); }
.stat small { font-size: 13px; font-weight: 400; color: var(--muted); }
.stats-note { margin: -10px 0 18px; font-size: 13px; }
.month-nav { display: flex; align-items: center; gap: 6px; }
.month-nav input[type=month] { padding: 5px 10px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; }
.inline-form { display: inline; }
.dash-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.table .num-col { text-align: right; white-space: nowrap; }
.table .total-row td { font-weight: 700; background: #f9fafb; }
.bar { height: 6px; background: #eef2ff; border-radius: 3px; margin-top: 4px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px 0; }
.card-head h2 { margin-bottom: 10px; }
.card-pad { padding: 0 20px 18px; }
.row-off td { opacity: .6; }
.thumb-cell { width: 76px; }
.thumb-sm { display: block; width: 64px; height: 44px; object-fit: cover; border-radius: 6px; }
.thumb-none { background: #f3f4f6; color: var(--muted); font-size: 11px; display: flex; align-items: center; justify-content: center; }
.img-preview img { max-width: 320px; max-height: 200px; border-radius: 8px; margin-bottom: 8px; display: block; }
.fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px 4px; margin: 6px 0 14px; }
.fieldset legend { padding: 0 6px; font-weight: 600; color: var(--navy); }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.err-detail { margin-top: 4px; font-size: 12px; color: var(--muted); }
.err-detail summary { cursor: pointer; }
.err-detail pre { white-space: pre-wrap; word-break: break-word; background: #f9fafb; padding: 8px; border-radius: 6px; max-width: 420px; }
@media (min-width: 900px) {
  .form-span-2 { grid-column: span 2; }
}
@media (max-width: 900px) {
  .admin-detail { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .table-stack td.thumb-cell { width: auto; }
  .card-head { padding: 14px 14px 0; }
  .card-pad { padding: 0 14px 14px; }
}
