/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #e8a020;
  --primary-dark:  #c47d0a;
  --primary-light: #fbbf24;
  --accent:        #f97316;
  --accent2:       #dc2626;
  --bg:            #0a0a0a;
  --bg2:           #111111;
  --bg3:           #1a1a1a;
  --card:          #161616;
  --card2:         #1e1e1e;
  --text:          #f5f0e8;
  --text-muted:    #8a8070;
  --border:        #2a2520;
  --border2:       #3a3530;
  --success:       #22c55e;
  --error:         #ef4444;
  --warning:       #f59e0b;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 8px 40px rgba(0,0,0,0.6);
  --glow:          0 0 24px rgba(232,160,32,0.15);
}

/* ===== Light Mode ===== */
body.light {
  --primary:       #c47d0a;
  --primary-dark:  #a06508;
  --primary-light: #e8a020;
  --accent:        #ea6f0a;
  --bg:            #f8f5f0;
  --bg2:           #eeebe4;
  --bg3:           #e4e0d8;
  --card:          #ffffff;
  --card2:         #f5f2ec;
  --text:          #1a1510;
  --text-muted:    #7a7060;
  --border:        #d8d0c4;
  --border2:       #c8c0b4;
  --shadow:        0 8px 40px rgba(0,0,0,0.12);
  --glow:          0 0 24px rgba(196,125,10,0.12);
}

html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', 'Noto Sans Thai', system-ui, sans-serif;
  min-height: 100vh;
  line-height: 1.6;
  transition: background 0.2s, color 0.2s;
}

.hidden { display: none !important; }
.container { max-width: 1000px; margin: 0 auto; padding: 28px 16px; }

/* ===== Pages ===== */
.page { display: none; min-height: 100vh; }
.page.active { display: block; }

/* ===== Hero ===== */
.hero {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 64px 24px 48px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(232,160,32,0.10) 0%, transparent 70%),
    radial-gradient(ellipse 40% 40% at 20% 60%, rgba(249,115,22,0.05) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 80% 60%, rgba(220,38,38,0.05) 0%, transparent 60%);
  pointer-events: none;
}
.hero-logo {
  width: 52px; height: 52px;
  margin: 0 auto 20px;
}
.hero-logo svg { width: 100%; height: 100%; }
.hero h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 900;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary) 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p { color: var(--text-muted); margin-top: 10px; font-size: 0.95rem; letter-spacing: 0.03em; }
.hero-admin-link {
  position: absolute; top: 16px; right: 20px;
  font-size: 0.72rem; color: var(--text-muted);
  text-decoration: none; letter-spacing: 0.06em;
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: 6px; transition: all 0.15s;
}
.hero-admin-link:hover { color: var(--primary); border-color: var(--primary); }

.theme-toggle {
  position: absolute; top: 16px; left: 20px;
  background: none; border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer;
  padding: 5px 10px; border-radius: 6px;
  font-size: 0.72rem; letter-spacing: 0.06em;
  transition: all 0.15s; font-family: inherit;
  display: flex; align-items: center; gap: 5px;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }
.theme-toggle svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ===== Top Bar ===== */
.top-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.btn-back {
  background: none; border: 1px solid var(--border2);
  color: var(--text-muted); cursor: pointer;
  padding: 7px 14px; border-radius: var(--radius-sm);
  font-size: 0.85rem; transition: all 0.15s; font-family: inherit;
}
.btn-back:hover { background: var(--bg3); color: var(--text); border-color: var(--primary); }
.top-title {
  font-weight: 800; font-size: 0.9rem; flex: 1;
  letter-spacing: 0.05em; text-transform: uppercase;
}

/* ===== Section Title ===== */
.section-title {
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 18px; padding-top: 4px;
}

/* ===== Concert Grid ===== */
.concert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.concert-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.concert-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow), var(--glow);
  border-color: rgba(232,160,32,0.4);
}
.concert-card-actions { display: flex; gap: 8px; padding: 0 12px 12px; }
.concert-card-actions .btn { flex: 1; font-size: 0.78rem; padding: 8px 6px; }
.concert-cover {
  width: 100%; height: 160px;
  background: linear-gradient(160deg, #140e04 0%, #0d0d0d 100%);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.concert-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.concert-cover-placeholder { width: 40px; height: 40px; opacity: 0.12; }
.concert-cover-placeholder svg { width: 100%; height: 100%; }
.concert-info { padding: 12px 12px 8px; }
.concert-info h3 {
  font-size: 0.9rem; font-weight: 800; margin-bottom: 5px;
  letter-spacing: 0.03em; text-transform: uppercase;
}
.concert-meta { display: flex; gap: 10px; flex-wrap: wrap; }
.concert-meta span { color: var(--text-muted); font-size: 0.78rem; }
.concert-badge {
  margin-top: 7px; display: inline-block;
  background: rgba(232,160,32,0.08); color: var(--primary);
  border: 1px solid rgba(232,160,32,0.25);
  padding: 2px 9px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em;
}

/* ===== Loading & Error ===== */
.loading-state, .error-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.spinner {
  width: 36px; height: 36px;
  border: 2px solid var(--border2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 16px;
}
.spinner.large { width: 52px; height: 52px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Upload Card ===== */
.upload-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 36px 28px;
  text-align: center; max-width: 520px; margin: 0 auto;
}
.upload-card h2 { font-size: 1.1rem; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.2px; }
.hint { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 24px; }
.preview-wrap { margin: 20px 0; }
#camera-video {
  width: 100%; max-width: 400px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--primary); display: block; margin: 0 auto;
}
#selfie-preview {
  width: 180px; height: 180px; object-fit: cover;
  border-radius: 50%; border: 2px solid var(--primary);
  display: block; margin: 0 auto 12px;
}
.camera-controls { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.upload-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 700; cursor: pointer;
  border: none; transition: all 0.15s; text-decoration: none;
  font-family: inherit; letter-spacing: 0.03em;
}
.btn-primary { background: var(--primary); color: #000; }
.btn-primary:hover { background: var(--primary-light); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #c91e1e; }
.btn-success { background: var(--success); color: #000; }
.btn-success:hover { background: #16a34a; }
.btn-outline { background: transparent; border: 1px solid var(--border2); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: var(--bg3); border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); }
.btn-dashed { background: var(--bg3); border: 1.5px dashed var(--border2); color: var(--text-muted); cursor: pointer; }
.btn-dashed:hover { border-color: var(--primary); color: var(--primary); }
.btn-large { width: 100%; max-width: 320px; padding: 13px; font-size: 0.92rem; margin: 8px auto 0; display: flex; }
.btn.small { padding: 6px 11px; font-size: 0.75rem; }
.progress-wrap { padding: 24px; color: var(--text-muted); }

/* ===== Results ===== */
.results-summary {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 13px 17px; margin-bottom: 14px; font-size: 0.9rem; color: var(--text-muted);
}
.results-summary strong { color: var(--primary); font-size: 1.3rem; }
.results-actions { margin-bottom: 14px; }
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 10px;
}
.result-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
  transition: transform 0.15s, border-color 0.15s;
}
.result-item:hover { transform: scale(1.02); border-color: rgba(232,160,32,0.4); }
.result-item img { width: 100%; height: 165px; object-fit: cover; display: block; }
.result-info { padding: 7px 8px; }
.similarity-badge {
  display: inline-block;
  background: rgba(34,197,94,0.08); color: var(--success);
  border: 1px solid rgba(34,197,94,0.25);
  padding: 1px 7px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em;
}
.result-actions { display: flex; gap: 5px; margin-top: 5px; }
.result-actions a, .result-actions button {
  flex: 1; padding: 5px; border-radius: 6px; font-size: 0.72rem;
  text-align: center; text-decoration: none; cursor: pointer; border: none;
  font-family: inherit; font-weight: 600; transition: all 0.12s;
}
.btn-view { background: var(--bg3); color: var(--text-muted); border: 1px solid var(--border); }
.btn-view:hover { color: var(--text); }
.btn-dl { background: var(--primary); color: #000; }
.btn-dl:hover { background: var(--primary-light); }
.no-results { text-align: center; padding: 60px 20px; }
.no-results h3 { font-size: 1.1rem; margin-bottom: 8px; font-weight: 700; }
.no-results p { color: var(--text-muted); margin-bottom: 20px; font-size: 0.88rem; }

/* ===== Lightbox ===== */
.lightbox {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.95);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 20px;
}
.lightbox-close {
  position: absolute; top: 16px; right: 20px;
  background: var(--card2); border: 1px solid var(--border2);
  color: var(--text-muted); font-size: 1rem;
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.15s;
}
.lightbox-close:hover { color: var(--text); border-color: var(--primary); }
#lightbox-img { max-width: 90vw; max-height: 74vh; object-fit: contain; border-radius: var(--radius); margin-bottom: 16px; }
.lightbox-btn { margin-top: 8px; }

/* ===== Admin Page ===== */
.admin-tabs {
  display: flex; gap: 3px;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 3px; margin-bottom: 24px; width: fit-content;
}
.admin-tab {
  padding: 7px 18px; border-radius: 6px;
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer; border: none; background: transparent;
  color: var(--text-muted); transition: all 0.15s; font-family: inherit;
}
.admin-tab.active { background: var(--primary); color: #000; }
.admin-tab:hover:not(.active) { color: var(--text); }
.admin-panel { display: none; }
.admin-panel.active { display: block; }

.admin-concert-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 8px; transition: border-color 0.15s;
}
.admin-concert-item:hover { border-color: var(--border2); }
.admin-concert-item.is-hidden { opacity: 0.4; }
.admin-concert-thumb {
  width: 60px; height: 44px; border-radius: 6px;
  background: var(--bg3); object-fit: cover; flex-shrink: 0;
  border: 1px solid var(--border); display: flex;
  align-items: center; justify-content: center; overflow: hidden;
}
.admin-concert-thumb img { width: 100%; height: 100%; object-fit: cover; }
.admin-concert-thumb svg { width: 22px; height: 22px; opacity: 0.18; }
.admin-concert-info { flex: 1; min-width: 0; }
.admin-concert-info h4 {
  font-size: 0.83rem; font-weight: 800;
  letter-spacing: 0.04em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.admin-concert-info p { font-size: 0.72rem; color: var(--text-muted); margin-top: 1px; }
.admin-concert-actions { display: flex; gap: 5px; flex-shrink: 0; flex-wrap: wrap; }

.cover-dropzone {
  border: 2px dashed var(--border2); border-radius: var(--radius-sm);
  padding: 24px; text-align: center; cursor: pointer;
  transition: all 0.2s; background: var(--bg3); position: relative;
}
.cover-dropzone:hover, .cover-dropzone.dragover { border-color: var(--primary); background: rgba(232,160,32,0.03); }
.cover-dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.cover-dropzone p { color: var(--text-muted); font-size: 0.82rem; pointer-events: none; }
.cover-preview { width: 100%; max-height: 150px; object-fit: cover; border-radius: var(--radius-sm); margin-top: 10px; display: none; }

.photo-upload-zone {
  border: 2px dashed var(--border2); border-radius: var(--radius-sm);
  padding: 32px; text-align: center; cursor: pointer;
  transition: all 0.2s; background: var(--bg3);
  position: relative; margin-bottom: 14px;
}
.photo-upload-zone:hover, .photo-upload-zone.dragover { border-color: var(--primary); background: rgba(232,160,32,0.03); }
.photo-upload-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.photo-upload-zone h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 5px; }
.photo-upload-zone p { color: var(--text-muted); font-size: 0.8rem; pointer-events: none; }

.upload-queue { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.upload-queue-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 11px; font-size: 0.78rem;
}
.upload-queue-item .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.upload-queue-item .fsize { color: var(--text-muted); flex-shrink: 0; font-size: 0.7rem; }
.upload-queue-item .fstatus { flex-shrink: 0; font-weight: 700; font-size: 0.68rem; letter-spacing: 0.05em; text-transform: uppercase; }
.fstatus.pending { color: var(--text-muted); }
.fstatus.uploading { color: var(--warning); }
.fstatus.done { color: var(--success); }
.fstatus.error { color: var(--error); }

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 5px; }
.form-input {
  width: 100%; background: var(--bg3); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 9px 11px; font-size: 0.88rem; font-family: inherit;
  transition: border-color 0.15s; outline: none;
}
.form-input:focus { border-color: var(--primary); }
.form-input::placeholder { color: var(--text-muted); }

.admin-select-concert {
  background: var(--bg3); border: 1px solid var(--border2);
  color: var(--text); padding: 8px 11px; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-family: inherit; cursor: pointer;
  outline: none; transition: border-color 0.15s;
}
.admin-select-concert:focus { border-color: var(--primary); }

.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.8);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: var(--card); border: 1px solid var(--border2);
  border-radius: var(--radius); padding: 26px;
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
}
.modal h3 { font-size: 0.92rem; font-weight: 800; margin-bottom: 18px; letter-spacing: 0.04em; text-transform: uppercase; }
.modal-actions { display: flex; gap: 7px; margin-top: 18px; justify-content: flex-end; }

.badge { display: inline-block; padding: 2px 7px; border-radius: 20px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.badge-hidden { background: rgba(239,68,68,0.1); color: var(--error); border: 1px solid rgba(239,68,68,0.2); }
.badge-visible { background: rgba(34,197,94,0.08); color: var(--success); border: 1px solid rgba(34,197,94,0.2); }
.badge-count { background: rgba(232,160,32,0.08); color: var(--primary); border: 1px solid rgba(232,160,32,0.2); }

.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.login-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px 28px;
  max-width: 360px; margin: 80px auto; text-align: center;
}
.login-card h2 { font-size: 1rem; font-weight: 800; margin-bottom: 4px; letter-spacing: 0.05em; text-transform: uppercase; }
.login-card p { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 22px; }
.login-error { color: var(--error); font-size: 0.8rem; margin-top: 8px; }

/* ===== Responsive ===== */
@media (max-width: 520px) {
  .concert-grid { grid-template-columns: 1fr; }
  .results-grid { grid-template-columns: repeat(2, 1fr); }
  .upload-actions { flex-direction: column; align-items: center; }
  .admin-concert-item { flex-wrap: wrap; }
  .admin-concert-actions { width: 100%; }
  .admin-tabs { overflow-x: auto; }
}
