/* ============================================
   SHOWROOM - Modern Ecommerce CSS
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg: #f4f6fb;
  --bg-card: #ffffff;
  --bg-nav: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --accent: #6c63ff;
  --accent-hover: #5a52e0;
  --border: #e5e7eb;
  --shadow: 0 4px 24px rgba(108, 99, 255, 0.08);
  --shadow-hover: 0 12px 40px rgba(108, 99, 255, 0.18);
  --radius: 16px;
  --radius-sm: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Dark Mode ---------- */
[data-theme="dark"] {
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-nav: #13132a;
  --text: #f1f1f1;
  --text-secondary: #9ca3af;
  --accent: #7c73ff;
  --accent-hover: #6c63ff;
  --border: #2d2d4e;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 12px 40px rgba(124, 115, 255, 0.25);
}

/* ---------- Reset ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', 'Noto Sans Thai', sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background var(--transition), color var(--transition);
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
  display: block;
}

/* ---------- Navbar ---------- */
.navbar {
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background var(--transition);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 16px;
}

.nav-logo {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.nav-logo span {
  color: var(--text);
}

/* Search — center column */
.nav-search {
  position: relative;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.nav-search input {
  width: 100%;
  padding: 10px 16px 10px 42px;
  border: 1.5px solid var(--border);
  border-radius: 24px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.nav-search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.12);
}

.nav-search input::placeholder {
  color: var(--text-secondary);
}

.nav-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
  font-size: 1rem;
  pointer-events: none;
}

/* Nav links — after search */
.nav-links {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.nav-links a {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition), background var(--transition);
  white-space: nowrap;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
  background: rgba(108, 99, 255, 0.08);
}

/* Dark mode toggle — rightmost */
.btn-dark {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.btn-dark:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ---------- Image Slider ---------- */
.slider-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #e0e7ff 0%, #f0e6ff 100%);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

[data-theme="dark"] .slider-wrap {
  background: linear-gradient(135deg, #1e1e3f 0%, #2d1b4e 100%);
}

.slider-track {
  display: flex;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider-slide {
  min-width: 100%;
  height: 100%;
}

.slider-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.slider-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.45);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 2;
}

.slider-btn:hover { background: var(--accent); }
.slider-btn.prev { left: 10px; }
.slider-btn.next { right: 10px; }
.slider-btn.hidden { display: none; }

.slider-dots {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
}

.slider-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.slider-dot.active {
  background: #fff;
  transform: scale(1.3);
}

/* ---------- Image Upload (Admin) ---------- */
.img-upload-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 4px;
}

.img-upload-slot {
  aspect-ratio: 3/4;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  background: var(--bg);
  user-select: none;
}

.img-upload-slot:hover,
.img-upload-slot.drag-over {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.12);
}

/* Hide native file input but keep it clickable */
.img-upload-slot input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  z-index: 2;
}

.slot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
  padding: 8px;
  text-align: center;
}

.slot-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.slot-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.slot-hint {
  font-size: 0.65rem;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Preview image */
.slot-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
  z-index: 1;
}

.img-upload-slot.has-img .slot-preview { display: block; }
.img-upload-slot.has-img .slot-inner { display: none; }
.img-upload-slot.has-img { border-style: solid; border-color: var(--accent); }

/* Overlay on hover when has image */
.slot-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 3;
}

.img-upload-slot.has-img:hover .slot-overlay { display: flex; }

.slot-overlay-btn {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  font-family: inherit;
  width: 80%;
  text-align: center;
}

.slot-btn-change {
  background: var(--accent);
  color: #fff;
}

.slot-btn-delete {
  background: #ef4444;
  color: #fff;
}

/* Remove button (always visible top-right) */
.slot-remove {
  position: absolute;
  top: 6px; right: 6px;
  width: 24px; height: 24px;
  background: rgba(239,68,68,0.9);
  color: #fff;
  border: 2px solid #fff;
  border-radius: 50%;
  font-size: 0.75rem;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 5;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.img-upload-slot.has-img .slot-remove { display: flex; }

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, var(--accent) 0%, #a78bfa 100%);
  padding: 64px 24px;
  text-align: center;
  color: #fff;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -1px;
}

.hero p {
  font-size: 1.1rem;
  opacity: 0.9;
  max-width: 480px;
  margin: 0 auto;
}

/* ---------- Section ---------- */
.section {
  max-width: 1280px;
  margin: 0 auto;
  padding: 48px 24px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.product-count {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ---------- Product Grid ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
}

/* ---------- Product Card ---------- */
.product-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
}

.card-image {
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: linear-gradient(135deg, #e0e7ff 0%, #f0e6ff 100%);
  position: relative;
}

[data-theme="dark"] .card-image {
  background: linear-gradient(135deg, #1e1e3f 0%, #2d1b4e 100%);
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition);
}

.product-card:hover .card-image img {
  transform: scale(1.06);
}

/* Placeholder when image fails */
.card-image .img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--accent);
  opacity: 0.4;
}

.card-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.card-price {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent);
}

.card-price::before {
  content: "฿";
  font-size: 0.85rem;
  margin-right: 2px;
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.btn-detail {
  margin-top: 12px;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background var(--transition), transform 0.1s;
  letter-spacing: 0.3px;
}

.btn-detail:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-detail:active {
  transform: translateY(0);
}

/* ---------- No Results ---------- */
.no-results {
  text-align: center;
  padding: 80px 24px;
  color: var(--text-secondary);
  grid-column: 1 / -1;
}

.no-results .icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.no-results h3 {
  font-size: 1.2rem;
  margin-bottom: 8px;
  color: var(--text);
}

/* ---------- Product Detail Page ---------- */
.detail-wrapper {
  max-width: 1100px;
  margin: 48px auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: start;
}

.detail-gallery .main-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
  background: linear-gradient(135deg, #e0e7ff 0%, #f0e6ff 100%);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.gallery-thumbs {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.gallery-thumbs img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
}

.gallery-thumbs img:hover,
.gallery-thumbs img.active {
  border-color: var(--accent);
  transform: scale(1.05);
}

.detail-info {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
  transition: gap var(--transition);
  cursor: pointer;
  background: none;
  border: none;
}

.back-btn:hover {
  gap: 10px;
}

.detail-name {
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
}

.detail-price {
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent);
}

.detail-price::before {
  content: "฿";
  font-size: 1.3rem;
}

.detail-desc {
  font-size: 1rem;
  color: var(--text-secondary);
  line-height: 1.8;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(108, 99, 255, 0.1);
  color: var(--accent);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid rgba(108, 99, 255, 0.2);
}

/* ---------- Admin Page ---------- */
.admin-wrapper {
  max-width: 720px;
  margin: 48px auto;
  padding: 0 24px;
}

.admin-title {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.admin-sub {
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.form-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.12);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

.btn-submit {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), transform 0.1s;
  letter-spacing: 0.4px;
}

.btn-submit:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

/* JSON Output */
.json-output {
  margin-top: 32px;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
  display: none;
}

.json-output.show { display: block; }

.json-output h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.json-output pre {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 0.8rem;
  overflow-x: auto;
  color: var(--accent);
  border: 1px solid var(--border);
  line-height: 1.6;
}

.success-toast {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: #10b981;
  color: #fff;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-weight: 500;
}

.success-toast.show { display: flex; }

/* ---------- Loading ---------- */
.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 24px;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  padding: 32px 24px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 48px;
}

/* ---------- Hamburger ---------- */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  padding: 6px;
  background: none;
  border: none;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all var(--transition);
}

.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile Menu Dropdown */
.mobile-menu {
  display: none;
  flex-direction: column;
  background: var(--bg-nav);
  border-top: 1px solid var(--border);
  padding: 8px 16px 16px;
}

.mobile-menu.open { display: flex; }

.mobile-menu a {
  padding: 12px 8px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  transition: color var(--transition);
}

.mobile-menu a:last-child { border-bottom: none; }
.mobile-menu a:hover, .mobile-menu a.active { color: var(--accent); }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 40px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.page-btn:hover { border-color: var(--accent); color: var(--accent); }

.page-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.page-dots {
  color: var(--text-secondary);
  font-size: 0.9rem;
  padding: 0 4px;
  line-height: 38px;
}

/* ---------- Admin Mobile Tabs ---------- */
.admin-tabs {
  display: none;
  gap: 0;
  margin-bottom: 20px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid var(--border);
}

.admin-tab-btn {
  flex: 1;
  padding: 12px;
  background: var(--bg-card);
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.admin-tab-btn.active {
  background: var(--accent);
  color: #fff;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .nav-links { display: none; }
  .hamburger { display: flex; }

  .nav-inner {
    grid-template-columns: auto 1fr auto auto;
    gap: 8px;
    padding: 0 16px;
  }

  .nav-logo { font-size: 1rem; }

  .detail-wrapper {
    grid-template-columns: 1fr;
    gap: 32px;
    margin: 24px auto;
  }

  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 16px;
  }

  .section { padding: 32px 16px; }
  .hero { padding: 40px 16px; }
}

@media (max-width: 480px) {
  .product-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .card-body { padding: 12px; }
  .card-name { font-size: 0.85rem; }
  .card-price { font-size: 1rem; }
}

/* Admin mobile tabs */
@media (max-width: 900px) {
  .admin-tabs { display: flex; }
  .form-panel.hidden-mobile,
  .list-panel.hidden-mobile { display: none; }
}
