/* ─── ตู้ชาร์ท.com — design system ─── */

:root {
  /* Surfaces — dark default */
  --bg: #080f1a;
  --bg-2: #0c1522;
  --panel: #111d30;
  --panel-2: #172540;
  --line: #1e2f4a;
  --line-strong: #2a3f60;

  /* Text */
  --text: #e8f2ff;
  --text-2: #b8cce6;
  --muted: #7a9bbf;
  --muted-2: #5a7a9f;

  /* Accents */
  --accent: #22d3ee;
  --accent-strong: #06b6d4;
  --accent-glow: rgba(34,211,238,.3);
  --success: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;

  /* Brand provider hues */
  --ptt:    #3b82f6;
  --pea:    #a855f7;
  --elexa:  #22d3ee;
  --spark:  #f59e0b;
  --igreen: #22c55e;
  --other:  #94a3b8;

  /* Type */
  --font: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Segoe UI",
          "Noto Sans Thai", "IBM Plex Sans Thai", "Sarabun", "Helvetica Neue", Arial, sans-serif;

  /* Motion */
  --ease: cubic-bezier(.2,.7,.2,1);
  --t-fast: 120ms;
  --t-base: 200ms;
  --t-slow: 360ms;

  /* Radii */
  --r-1: 8px;
  --r-2: 12px;
  --r-3: 16px;
  --r-full: 999px;

  /* Shadows */
  --shadow-1: 0 1px 3px rgba(0,0,0,.35);
  --shadow-2: 0 8px 24px rgba(0,0,0,.45);
  --shadow-3: 0 16px 48px rgba(0,0,0,.55);

  --header-h: 62px;
  --list-head-bg: rgba(11,21,40,.88);
}

[data-theme="light"] {
  --bg: #f0f6ff;
  --bg-2: #e6f0fa;
  --panel: #ffffff;
  --panel-2: #eaf2fc;
  --line: #d0dff0;
  --line-strong: #b8cfe6;
  --text: #071428;
  --text-2: #1e3050;
  --muted: #5878a0;
  --muted-2: #88a0be;
  --shadow-1: 0 1px 3px rgba(0,0,0,.08);
  --shadow-2: 0 8px 24px rgba(0,0,0,.1);
  --shadow-3: 0 16px 48px rgba(0,0,0,.14);
  --list-head-bg: rgba(240,246,255,.92);
}
[data-theme="light"] .app-header {
  background: linear-gradient(180deg, #cce8ff 0%, var(--bg) 100%);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}
a { color: inherit; }
button { font-family: inherit; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ─── Header ─── */
.app-header {
  background: linear-gradient(180deg, #091830 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1100;
  backdrop-filter: blur(8px);
}
.app-header-inner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  min-height: var(--header-h);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--text);
  font-weight: 800; font-size: 16px; letter-spacing: -.02em;
  padding: 4px 8px;
  border-radius: var(--r-1);
  transition: background var(--t-fast);
  white-space: nowrap;
}
.brand:hover { background: var(--panel); }
.brand-icon {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
  box-shadow: 0 0 12px var(--accent-glow);
}
.brand-th { color: var(--accent); }
.brand-dot { color: var(--muted-2); font-weight: 400; }

.header-spacer { flex: 1; }
.header-stat { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ─── Nav ─── */
.main-nav { display: flex; align-items: center; gap: 2px; margin-left: 6px; }
.nav-link {
  display: inline-flex; align-items: center;
  padding: 6px 13px;
  border-radius: var(--r-full);
  font-size: 13.5px; font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
}
.nav-link:hover { background: var(--panel-2); color: var(--text); }
.nav-link.active { color: var(--accent); background: rgba(34,211,238,.1); }
.nav-link.nav-cta {
  background: var(--accent); color: #041020;
  font-weight: 700; margin-left: 4px;
}
.nav-link.nav-cta:hover { background: var(--accent-strong); }

.nav-hamburger {
  display: none; background: none; border: none;
  color: var(--muted); font-size: 20px; padding: 6px 8px;
  border-radius: var(--r-1); cursor: pointer; line-height: 1;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-hamburger:hover { background: var(--panel-2); color: var(--text); }

@media (max-width: 820px) {
  .nav-hamburger { display: flex; align-items: center; }
  .main-nav {
    position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; gap: 2px; padding: 8px 12px 16px;
    background: var(--panel); border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-2); display: none; z-index: 1099;
  }
  .main-nav.open { display: flex; }
  .nav-link { width: 100%; border-radius: var(--r-1); padding: 10px 16px; font-size: 15px; }
  .nav-link.nav-cta { margin-left: 0; margin-top: 4px; justify-content: center; }
  .header-stat { display: none; }
}

/* ─── Theme toggle ─── */
.theme-btn {
  background: none; border: 1px solid var(--line); color: var(--muted);
  padding: 6px 10px; border-radius: var(--r-full); cursor: pointer; font-size: 15px;
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
  line-height: 1; display: flex; align-items: center;
}
.theme-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(34,211,238,.07); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--r-full);
  font-size: 14px; font-weight: 600; font-family: inherit;
  cursor: pointer; border: none; text-decoration: none;
  transition: all var(--t-fast); white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #041020; }
.btn-primary:hover { background: var(--accent-strong); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: rgba(34,211,238,.07); }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ─── Input ─── */
.input {
  width: 100%; padding: 10px 14px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  border-radius: var(--r-1); font-family: inherit; font-size: 14px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input::placeholder { color: var(--muted-2); }
textarea.input { resize: vertical; min-height: 90px; }

/* ─── Chip / Filter buttons ─── */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 13px; border-radius: var(--r-full);
  font-size: 12.5px; font-weight: 600; font-family: inherit;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--muted);
  cursor: pointer; transition: all var(--t-fast); white-space: nowrap;
}
.chip:hover { border-color: var(--muted); color: var(--text); }
.chip.active { background: rgba(34,211,238,.12); border-color: var(--accent); color: var(--accent); }

/* ─── Provider badges ─── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; padding: 3px 9px;
  border-radius: var(--r-full); letter-spacing: .04em;
  border: 1px solid transparent;
}
.badge-ptt    { background: rgba(59,130,246,.15); color: #93c5fd; border-color: rgba(59,130,246,.3); }
.badge-pea    { background: rgba(168,85,247,.15); color: #d8b4fe; border-color: rgba(168,85,247,.3); }
.badge-elexa  { background: rgba(34,211,238,.12); color: var(--accent); border-color: rgba(34,211,238,.3); }
.badge-spark  { background: rgba(245,158,11,.15); color: #fcd34d; border-color: rgba(245,158,11,.3); }
.badge-igreen { background: rgba(34,197,94,.15); color: #86efac; border-color: rgba(34,197,94,.3); }
.badge-other  { background: rgba(148,163,184,.1); color: var(--muted); border-color: var(--line); }

/* ─── Status dot ─── */
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-open { background: var(--success); box-shadow: 0 0 6px rgba(52,211,153,.6); }
.status-busy { background: var(--warn); box-shadow: 0 0 6px rgba(251,191,36,.5); }
.status-offline { background: var(--danger); }
.status-unknown { background: var(--muted-2); }

/* ─── Section header ─── */
.section-h {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted-2); font-weight: 700; margin: 0 0 10px;
}

/* ─── Card ─── */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-2); overflow: hidden;
}

/* ─── Container ─── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* ─── Page layout (map + sidebar) ─── */
.page-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: calc(100vh - var(--header-h));
}
@media (max-width: 900px) {
  .page-layout { grid-template-columns: 1fr; grid-template-rows: 45vh 1fr; }
}

/* ─── Sidebar ─── */
.sidebar {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
  overflow: hidden;
  background: var(--bg);
}
.sidebar-controls { padding: 12px 14px 0; flex-shrink: 0; }
.search-wrap { position: relative; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted-2); pointer-events: none; font-size: 14px;
}
.search-wrap .input { padding-left: 36px; padding-right: 34px; }
.search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 4px 6px; border-radius: var(--r-1); display: none;
}
.search-clear:hover { color: var(--text); background: var(--panel-2); }
.search-wrap.has-value .search-clear { display: block; }

.filter-bar {
  display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 14px 12px;
  border-bottom: 1px solid var(--line);
}

.station-list-head {
  padding: 8px 14px; font-size: 11.5px; color: var(--muted);
  background: var(--list-head-bg);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  backdrop-filter: blur(4px);
  font-variant-numeric: tabular-nums;
}

.station-list {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
}
.station-list::-webkit-scrollbar { width: 4px; }
.station-list::-webkit-scrollbar-track { background: transparent; }
.station-list::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 2px; }

/* ─── Station row ─── */
.station-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background var(--t-fast);
  text-decoration: none;
  display: block;
  color: inherit;
}
.station-row:hover { background: var(--panel); }
.station-row.active { background: var(--panel-2); border-left: 3px solid var(--accent); }

.station-row-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 5px;
}
.station-name { font-weight: 600; font-size: 14px; line-height: 1.3; flex: 1; }
.station-heads {
  font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap;
  color: var(--muted); flex-shrink: 0;
}
.station-heads .dc { color: #fda4af; font-weight: 700; }
.station-heads .ac { color: #93c5fd; font-weight: 700; }
.station-row-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px;
}
.station-addr { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }

/* ─── Map ─── */
#map { flex: 1; z-index: 0; }
@media (max-width: 900px) {
  .sidebar { order: 2; }
  #map-wrap { order: 1; }
}

/* ─── Leaflet overrides ─── */
.leaflet-popup-content-wrapper {
  background: var(--panel) !important;
  border: 1px solid var(--line) !important;
  color: var(--text) !important;
  border-radius: var(--r-2) !important;
  box-shadow: var(--shadow-2) !important;
  padding: 0 !important;
}
.leaflet-popup-content { margin: 0 !important; font-family: var(--font) !important; }
.leaflet-popup-tip { background: var(--panel) !important; }
.leaflet-popup-close-button { color: var(--muted) !important; font-size: 18px !important; top: 8px !important; right: 8px !important; }
.leaflet-popup-close-button:hover { color: var(--text) !important; }
.leaflet-control-zoom a { background: var(--panel) !important; color: var(--text) !important; border-color: var(--line) !important; }
.leaflet-control-zoom a:hover { background: var(--panel-2) !important; }

/* ─── Map popup ─── */
.map-popup { padding: 14px 16px; min-width: 200px; max-width: 280px; }
.map-popup-name { font-weight: 700; font-size: 14px; margin-bottom: 6px; line-height: 1.3; }
.map-popup-meta { font-size: 12px; color: var(--muted); margin-bottom: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.map-popup-link {
  display: block; text-align: center; background: var(--accent); color: #041020;
  font-weight: 700; font-size: 13px; padding: 8px; border-radius: var(--r-1);
  text-decoration: none; transition: background var(--t-fast);
}
.map-popup-link:hover { background: var(--accent-strong); }

/* ─── Empty state ─── */
.empty-state {
  padding: 40px 20px; text-align: center; color: var(--muted);
}
.empty-state .icon { font-size: 36px; margin-bottom: 10px; }
.empty-state p { margin: 0; font-size: 14px; }

/* ─── Station detail page ─── */
.detail-layout {
  max-width: 900px; margin: 0 auto; padding: 0 20px 60px;
}
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 14px; text-decoration: none;
  padding: 6px 10px; border-radius: var(--r-1); margin: 16px 0;
  transition: background var(--t-fast), color var(--t-fast);
}
.back-link:hover { background: var(--panel); color: var(--text); }

.detail-hero { padding: 8px 0 20px; }
.detail-hero h1 {
  font-size: 28px; font-weight: 800; letter-spacing: -.025em;
  margin: 12px 0 8px; line-height: 1.25;
}
@media (max-width: 600px) { .detail-hero h1 { font-size: 22px; } }
.detail-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.detail-addr { color: var(--text-2); font-size: 14px; margin-top: 8px; line-height: 1.6; }

.detail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

#station-map {
  height: 340px; border-radius: var(--r-3); overflow: hidden;
  border: 1px solid var(--line); margin: 24px 0; box-shadow: var(--shadow-2);
}
@media (max-width: 600px) { #station-map { height: 240px; margin: 16px 0; } }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 500px) { .stat-row { grid-template-columns: 1fr 1fr; } }
.stat-box {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--r-2); padding: 14px 16px;
}
.stat-box .num { font-size: 32px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.stat-box .num.dc { color: #fda4af; }
.stat-box .num.ac { color: #93c5fd; }
.stat-box .lbl { font-size: 11px; color: var(--muted); margin-top: 6px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
@media (max-width: 700px) { .info-grid { grid-template-columns: 1fr; } }

.info-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-2); padding: 18px; }
.info-card h3 { margin: 0 0 14px; font-size: 13px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.info-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.info-row:last-child { border-bottom: none; }
.info-row .label { color: var(--muted); }
.info-row .value { font-weight: 600; }

/* ─── Reviews ─── */
.reviews-section { margin-top: 32px; }
.reviews-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.reviews-header h2 { margin: 0; font-size: 20px; font-weight: 700; }

.review-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-2); padding: 16px 18px; margin-bottom: 10px;
}
.review-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.reviewer-avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #041020; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.review-name { font-weight: 600; font-size: 14px; }
.review-time { color: var(--muted); font-size: 12px; }
.review-stars { font-size: 14px; }
.review-body { font-size: 14px; line-height: 1.6; color: var(--text-2); white-space: pre-wrap; }

/* Star picker */
.star-pick { display: inline-flex; gap: 2px; font-size: 30px; user-select: none; cursor: pointer; }
.star-pick span { color: var(--line-strong); transition: color var(--t-fast); line-height: 1; padding: 0 2px; }
.star-pick span.active { color: var(--warn); }
.star-pick span:hover ~ span { color: var(--line-strong) !important; }
.star-pick:hover span { color: var(--warn); }

/* ─── Review form modal ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 3000; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity var(--t-base);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-3); padding: 28px; width: 100%; max-width: 480px;
  box-shadow: var(--shadow-3);
  transform: translateY(20px) scale(.97); transition: transform var(--t-base);
}
.modal-overlay.open .modal { transform: none; }
.modal h3 { margin: 0 0 20px; font-size: 18px; font-weight: 700; }
.form-field { margin-bottom: 16px; }
.form-field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ─── About / static pages ─── */
.prose { max-width: 720px; margin: 0 auto; padding: 40px 20px 80px; }
.prose h1 { font-size: 30px; font-weight: 800; letter-spacing: -.025em; margin-bottom: 8px; }
.prose h2 { font-size: 20px; font-weight: 700; margin-top: 32px; margin-bottom: 12px; }
.prose p { color: var(--text-2); line-height: 1.75; margin-bottom: 14px; }
.prose ul { color: var(--text-2); line-height: 1.75; padding-left: 24px; }
.prose li { margin-bottom: 6px; }

/* ─── Interested form ─── */
.form-page { max-width: 600px; margin: 40px auto; padding: 0 20px 80px; }
.form-page h1 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.form-page .sub { color: var(--muted); margin-bottom: 28px; font-size: 14px; }
.form-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-3); padding: 28px; }
.form-card .form-field { margin-bottom: 18px; }
.form-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 500px) { .form-row { grid-template-columns: 1fr; } }
.form-card select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a9bbf' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }

/* ─── Toast ─── */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 4000; pointer-events: none; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line-strong);
  border-radius: var(--r-full); padding: 10px 20px;
  font-size: 14px; box-shadow: var(--shadow-2); color: var(--text);
  pointer-events: auto; animation: toast-in .2s var(--ease) both;
  white-space: nowrap;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }
@keyframes toast-in { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }

/* ─── Footer ─── */
.site-footer {
  border-top: 1px solid var(--line); padding: 28px 20px;
  text-align: center; color: var(--muted-2); font-size: 13px;
}
.site-footer a { color: var(--muted); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* ─── Scrollbar global ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 3px; }
