:root {
  /* Dark mode (default) */
  --bg: #020617;
  --bg-soft: #0b1220;
  --card: #020617;
  --border: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #2563eb;
  --accent-soft: #1d4ed8;
  --positive: #22c55e;
  --danger: #ef4444;
  --card-width: 260px;
}

/* Light mode */
:root.light {
  --bg: #f8fafc;
  --bg-soft: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-soft: #1d4ed8;
  --positive: #059669;
  --danger: #dc2626;
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

html { transition: background-color 0.3s ease; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-soft);
  color: var(--text);
  line-height: 1.6;
}

/* NAVBAR ELEGANT */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(2, 6, 23, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 70px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  font-weight: 800;
  font-size: 1.4rem;
}

.logo-mark {
  width: 45px;
  height: 45px;
  border-radius: 12px;
  background: linear-gradient(135deg, #38bdf8 0%, #2563eb 50%, #4f46e5 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.3rem;
  font-weight: 900;
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.4);
}

.logo-text {
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  gap: 2rem;
  margin-left: 3rem;
}

.nav-link {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  padding: 0.5rem 0;
  position: relative;
  transition: all 0.3s ease;
  font-size: 0.95rem;
}

.nav-link:hover, .nav-link.active {
  color: var(--accent);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, #38bdf8, #2563eb);
  border-radius: 1px;
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.catalog-btn {
  padding: 0.6rem 1.5rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: white;
  text-decoration: none;
  border-radius: 25px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}

.catalog-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.5);
}

.theme-btn {
  width: 42px;
  height: 42px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.3s ease;
}

.theme-btn:hover {
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.15);
  transform: scale(1.05);
}

.mobile-menu { display: none; }

/* Layout Utama */
.main {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.catalog-header h2 {
  margin: 0 0 0.5rem;
  font-size: 1.8rem;
  color: var(--text);
}

.catalog-header p {
  margin: 0 0 2rem;
  color: var(--muted);
}

/* FILTERS RAPI */
.catalog-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) 1fr 1fr 1.4fr;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.catalog-controls input,
.catalog-controls select {
  width: 100%;
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

/* FILTER HARGA RAPI */
.price-range {
  width: 100%;
}

.price-range label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.price-inputs {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.price-inputs input {
  flex: 1;
  min-width: 0;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
}

.price-inputs span {
  font-weight: 600;
  color: var(--muted);
  min-width: 20px;
  text-align: center;
}

@media (max-width: 900px) {
  .catalog-controls {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .catalog-controls {
    grid-template-columns: 1fr;
  }
}

/* Gaya umum untuk semua dropdown */
.catalog-controls select {
  background-color: #020617;      /* sama dengan --bg atau --bg-soft */
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding-right: 2rem;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

/* Warna saat hover/focus */
.catalog-controls select:hover {
  border-color: var(--accent);
}

.catalog-controls select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

/* Dropdown list (opsi) di dark mode */
.catalog-controls select option {
  background-color: #020617;
  color: #e5e7eb;
}

/* Saat dipilih (untuk sebagian browser) */
.catalog-controls select option:checked {
  background-color: #1d4ed8;
  color: #ffffff;
}
:root.light .catalog-controls select {
  background-color: #ffffff;
  color: #1f2933;
}

:root.light .catalog-controls select option {
  background-color: #ffffff;
  color: #1f2933;
}

/* GRID PRODUK */
.products-grid {
  display: grid;
  gap: 1.5rem;
  justify-content: center;
}

@media (min-width: 1200px) {
  .products-grid { grid-template-columns: repeat(4, var(--card-width)); }
}
@media (min-width: 900px) and (max-width: 1199px) {
  .products-grid { grid-template-columns: repeat(3, var(--card-width)); }
}
@media (min-width: 600px) and (max-width: 899px) {
  .products-grid { grid-template-columns: repeat(2, var(--card-width)); }
}
@media (max-width: 599px) {
  .products-grid {
    grid-template-columns: 1fr;
    max-width: 340px;
    margin: 0 auto;
  }
}

/* PRODUCT CARD */
.product-card {
  background: var(--card);
  border-radius: 1rem;
  border: 1px solid var(--border);
  padding: 1.25rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 420px;
  transition: all 0.3s ease;
}

.product-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.25);
}

.product-card img {
  width: 100%;
  height: 160px;
  border-radius: 0.75rem;
  object-fit: cover;
  background: var(--bg-soft);
}

.product-card h3 {
  margin: 1rem 0 0.5rem;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text);
}

.product-card .brand {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.product-card .spec {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.price {
  margin: 0 0 1rem;
  font-weight: 700;
  color: var(--positive);
  font-size: 1.1rem;
}

.old-price {
  text-decoration: line-through;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85em;
  margin-left: 0.5rem;
}

.status {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.status.ready { color: var(--positive); }
.status.habis { color: var(--danger); }

.card-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}

.detail-btn {
  flex: 1;
  padding: 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.buy-btn {
  flex: 1;
  padding: 0.6rem;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.detail-btn:hover { 
  border-color: var(--accent);
  background: rgba(37, 99, 235, 0.1);
}
.buy-btn:hover { 
  background: var(--accent-soft);
  transform: translateY(-2px);
}

/* MODAL */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(8px);
}

.modal-content {
  background: var(--card);
  border-radius: 1.25rem;
  max-width: 950px;
  max-height: 92vh;
  width: 95%;
  height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 35px 80px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.75rem 2rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.75rem;
  color: var(--text);
}

.modal-close {
  background: none;
  border: none;
  font-size: 2.25rem;
  cursor: pointer;
  color: var(--muted);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.modal-body { display: flex; flex: 1; overflow: hidden; }

.modal-gallery {
  flex: 1;
  max-width: 52%;
}

.modal-gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-info {
  flex: 1;
  padding: 2.5rem;
  overflow-y: auto;
}

.modal-brand {
  font-size: 1.15rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.modal-price {
  font-size: 2rem;
  font-weight: 800;
  color: var(--positive);
  margin-bottom: 2rem;
}

.modal-specs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.spec-item { display: flex; flex-direction: column; }

.spec-label {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.spec-value {
  font-weight: 600;
  color: var(--text);
  font-size: 1.05rem;
}

.modal-desc,
.modal-highlight {
  margin-bottom: 1.25rem;
  line-height: 1.7;
}

.modal-highlight {
  background: rgba(37, 99, 235, 0.12);
  padding: 1.25rem;
  border-radius: 0.75rem;
  border-left: 5px solid var(--accent);
}

.modal-stock {
  font-size: 1rem;
  padding: 1rem;
  border-radius: 0.75rem;
  margin-bottom: 2rem;
  font-weight: 600;
}

.modal-buy-btn {
  display: block;
  width: 100%;
  padding: 1.25rem;
  text-align: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-soft));
  color: white;
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.3s ease;
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.4);
}

.modal-buy-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 40px rgba(37, 99, 235, 0.6);
}

/* FOOTER */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.75rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 4rem;
}

/* LIGHT MODE OVERRIDES */
:root.light body {
  background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 50%, #f8fafc 100%);
}

:root.light .navbar {
  background: rgba(255, 255, 255, 0.98);
  border-bottom-color: var(--border);
}

:root.light .logo-mark {
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.3);
}

:root.light .theme-btn {
  border-color: var(--border);
  background: rgba(0, 0, 0, 0.08);
}

:root.light .product-card {
  background: #ffffff;
  border-color: var(--border);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08);
}

:root.light .catalog-controls input,
:root.light .catalog-controls select {
  background: rgba(255, 255, 255, 0.95);
  border-color: var(--border);
}

:root.light .price-inputs input {
  background: rgba(255, 255, 255, 0.98);
}

/* RESPONSIVE */
/* ========== MOBILE NAVBAR RAPi & PROFESSIONAL ========== */
@media (max-width: 768px) {
  /* Sembunyikan desktop nav */
  .nav-links { display: none; }
  .mobile-menu { display: none !important; }
  
  /* Navbar container: space-between perfect */
  .nav-container {
    padding: 0 1rem;
    height: 65px;
    justify-content: space-between !important;
    align-items: center;
  }
  
  /* Logo lebih kecil di mobile */
  .logo {
    font-size: 1.2rem;
  }
  
  .logo-mark {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }
  
  /* ========== NAV-RIGHT: 3 ELEMEN RAPI ========== */
  .nav-right {
    display: flex !important;
    align-items: center;
    gap: 0.4rem;  /* Gap minimal */
    min-width: 140px;
  }
  
  /* 1. Form Button: Prioritas #1 */
  .catalog-btn {
    display: flex !important;
    padding: 0.45rem 0.95rem;  /* Kompak */
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 20px;
    white-space: nowrap;
    min-width: 105px;  /* Pastikan tidak mengecil */
    justify-content: center;
  }
  
  /* 2. Theme Toggle: Prioritas #2 (paling kanan) */
  .theme-btn {
    flex-shrink: 0 !important;  /* TIDAK BOLEH MENGECEK */
    width: 40px;
    height: 40px;
    margin-left: 0.2rem;
    order: 2;
  }
  
  /* Pastikan tidak overlap */
  .nav-right > * {
    flex-shrink: 0;
  }
}

/* Extra small screens */
@media (max-width: 480px) {
  .nav-container { padding: 0 0.8rem; }
  .catalog-btn {
    padding: 0.4rem 0.85rem;
    font-size: 0.75rem;
    min-width: 98px;
  }
  .logo-mark { width: 36px; height: 36px; }
}


@media (max-width: 480px) {
  .price-inputs { flex-direction: column; align-items: stretch; gap: 0.5rem; }
}
