/* ============================================================
   style.css — Price Tracker Dashboard
   Dark theme, modern, premium feel
   ============================================================ */

/* --- DESIGN TOKENS --- */
:root {
  --color-bg: #0d0d1a;
  --color-surface: #13132a;
  --color-surface-2: #1a1a35;
  --color-border: rgba(255, 255, 255, 0.07);
  
  --color-primary: #6c63ff;
  --color-primary-hover: #5a52e0;
  --color-primary-glow: rgba(108, 99, 255, 0.2);
  
  --color-shopee: #ee4d2d;
  --color-tokopedia: #42b549;
  
  --color-text: #e2e8f0;
  --color-text-muted: #718096;
  --color-text-dim: #4a5568;
  
  --color-green: #68d391;
  --color-red: #fc8181;
  --color-yellow: #f6e05e;
  
  --sidebar-width: 240px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --transition: 0.2s ease;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px rgba(108, 99, 255, 0.15);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--color-bg); }
::-webkit-scrollbar-thumb { background: var(--color-surface-2); border-radius: 3px; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--color-border);
}

.logo-icon { font-size: 24px; }

.logo-text {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.logo-id {
  color: var(--color-primary);
  font-weight: 800;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--border-radius-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}

.nav-link:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.nav-link.active {
  background: var(--color-primary-glow);
  color: var(--color-primary);
  font-weight: 600;
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
}

.sidebar-version {
  font-size: 11px;
  color: var(--color-text-dim);
}

/* Mobile menu button — hidden on desktop */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 16px; left: 16px;
  z-index: 200;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  width: 40px; height: 40px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  font-size: 18px;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ============================================================
   VIEWS (SPA routing)
   ============================================================ */
.view {
  display: none;
  animation: fadeIn 0.25s ease;
}

.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 16px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ============================================================
   STATS BAR
   ============================================================ */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.stat-icon { font-size: 28px; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ============================================================
   PRODUCTS GRID
   ============================================================ */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.product-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow);
}

.product-card.inactive {
  opacity: 0.5;
}

.product-card-header {
  position: relative;
  height: 180px;
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

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

.product-img-placeholder {
  font-size: 60px;
  opacity: 0.3;
}

.product-badges {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.product-card-body {
  padding: 16px;
}

.product-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  margin-bottom: 4px;
}

.product-shop {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 12px;
}

.product-price-section {
  margin-bottom: 10px;
}

.product-price {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
}

.product-target {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.product-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--color-text-dim);
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-shopee {
  background: rgba(238, 77, 45, 0.2);
  color: #ff7857;
}

.badge-tokopedia {
  background: rgba(66, 181, 73, 0.2);
  color: #68d391;
}

.badge-low {
  background: rgba(246, 224, 94, 0.2);
  color: var(--color-yellow);
}

.badge-active {
  background: rgba(104, 211, 145, 0.15);
  color: var(--color-green);
}

.badge-inactive {
  background: rgba(113, 128, 150, 0.2);
  color: var(--color-text-muted);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 40px;
}

.empty-icon { font-size: 60px; margin-bottom: 16px; }

.empty-state h3 {
  font-size: 20px;
  color: #fff;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--color-text-muted);
  margin-bottom: 24px;
}

/* ============================================================
   PRODUCT DETAIL
   ============================================================ */
.detail-back { margin-bottom: 20px; }

.detail-header {
  display: flex;
  gap: 28px;
  margin-bottom: 28px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 28px;
}

.detail-img {
  width: 220px;
  height: 220px;
  object-fit: cover;
  border-radius: var(--border-radius-sm);
  flex-shrink: 0;
}

.detail-img-placeholder {
  width: 220px;
  height: 220px;
  background: var(--color-surface-2);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 70px;
  flex-shrink: 0;
}

.detail-info { flex: 1; }

.detail-badges { display: flex; gap: 8px; margin-bottom: 12px; }

.detail-name {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  line-height: 1.4;
  margin-bottom: 6px;
}

.detail-shop {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.detail-price-section { margin-bottom: 20px; }

.detail-current-price {
  font-size: 32px;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1;
}

.price-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 20px;
}

.price-down { color: var(--color-green); background: rgba(104, 211, 145, 0.1); }
.price-up { color: var(--color-red); background: rgba(252, 129, 129, 0.1); }
.price-same { color: var(--color-text-muted); background: var(--color-surface-2); }

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

/* Stats Grid (4 kotak) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  padding: 18px;
  text-align: center;
}

.stat-box-label {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

.stat-box-value {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.text-green { color: var(--color-green); }
.text-red { color: var(--color-red); }

/* Target Section */
.target-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 24px;
  margin-bottom: 24px;
}

.target-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.target-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.target-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
}

.target-reached {
  background: rgba(104, 211, 145, 0.1);
  color: var(--color-green);
  border: 1px solid rgba(104, 211, 145, 0.2);
}

.target-pending {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}

/* Chart Section */
.chart-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 24px;
  margin-bottom: 24px;
}

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

.chart-header h3 { font-size: 16px; font-weight: 600; }

.chart-controls {
  display: flex;
  gap: 6px;
}

.btn-range {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-range:hover, .btn-range.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.chart-container {
  position: relative;
  height: 260px;
}

/* ============================================================
   FORMS
   ============================================================ */
.add-product-container {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 28px;
  align-items: start;
}

.add-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 28px;
}

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

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

.required { color: var(--color-red); }
.optional { color: var(--color-text-dim); font-weight: 400; font-size: 12px; }

.input-field {
  width: 100%;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  padding: 12px 16px;
  color: var(--color-text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color var(--transition);
  outline: none;
}

.input-field:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.input-field::placeholder { color: var(--color-text-dim); }

.input-large { font-size: 15px; padding: 14px 16px; }

select.input-field { cursor: pointer; }

.input-prefix-group {
  display: flex;
  align-items: center;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  transition: border-color var(--transition);
}

.input-prefix-group:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-glow);
}

.input-prefix {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--color-text-muted);
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
  white-space: nowrap;
}

.input-prefix-group .input-field {
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.form-hint {
  font-size: 12px;
  color: var(--color-text-dim);
  margin-top: 6px;
  line-height: 1.5;
}

.form-hint a {
  color: var(--color-primary);
  text-decoration: none;
}

.add-status {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  display: none;
}

.add-status:not(:empty) { display: block; }

.add-status.info {
  background: rgba(108, 99, 255, 0.1);
  color: var(--color-primary);
  border: 1px solid var(--color-primary-glow);
}

.add-status.success {
  background: rgba(104, 211, 145, 0.1);
  color: var(--color-green);
  border: 1px solid rgba(104, 211, 145, 0.2);
}

.add-status.error {
  background: rgba(252, 129, 129, 0.1);
  color: var(--color-red);
  border: 1px solid rgba(252, 129, 129, 0.2);
}

/* Tips Card */
.tips-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 24px;
}

.tips-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 14px;
}

.tips-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tips-list li {
  font-size: 13px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.tips-list code {
  background: var(--color-surface-2);
  color: var(--color-primary);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-container {
  max-width: 600px;
}

.settings-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 28px;
  margin-bottom: 20px;
}

.settings-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.settings-desc {
  font-size: 13px;
  color: var(--color-text-muted);
  margin-bottom: 20px;
}

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

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--border-radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 0 0 0 var(--color-primary-glow);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
  box-shadow: 0 0 12px var(--color-primary-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-surface);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-surface-2);
  color: var(--color-text);
}

.btn-danger {
  background: rgba(252, 129, 129, 0.1);
  color: var(--color-red);
  border: 1px solid rgba(252, 129, 129, 0.2);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(252, 129, 129, 0.2);
}

.btn-large {
  padding: 14px 28px;
  font-size: 15px;
  width: 100%;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
}

.toast {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  padding: 13px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  transform: translateX(120%);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 360px;
}

.toast.show { transform: translateX(0); }

.toast-success { border-left: 3px solid var(--color-green); }
.toast-error { border-left: 3px solid var(--color-red); }
.toast-info { border-left: 3px solid var(--color-primary); }

/* ============================================================
   LOADING STATES
   ============================================================ */
.loading-skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface) 25%,
    var(--color-surface-2) 50%,
    var(--color-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--border-radius);
  height: 280px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.loading-spinner {
  text-align: center;
  padding: 60px;
  color: var(--color-text-muted);
  font-size: 16px;
}

/* ============================================================
   ERROR & MISC
   ============================================================ */
.error-msg {
  color: var(--color-red);
  background: rgba(252, 129, 129, 0.1);
  border: 1px solid rgba(252, 129, 129, 0.2);
  border-radius: var(--border-radius-sm);
  padding: 14px 18px;
  font-size: 14px;
  grid-column: 1 / -1;
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 900px) {
  .add-product-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
  }

  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }

  .main-content {
    margin-left: 0;
    padding: 20px 16px;
    padding-top: 70px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-title { font-size: 22px; }

  .products-grid {
    grid-template-columns: 1fr;
  }

  .detail-header {
    flex-direction: column;
  }

  .detail-img, .detail-img-placeholder {
    width: 100%;
    height: 200px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-actions {
    flex-direction: column;
  }

  .detail-actions .btn {
    width: 100%;
  }
}

/* ============================================================
   VARIANTS SECTION — Pills harga per warna/ukuran
   ============================================================ */
.badge-variant {
  background: rgba(167, 139, 250, 0.15);
  color: #a78bfa;
}

.price-range-note {
  font-size: 12px;
  color: var(--color-text-dim);
  margin-top: 4px;
  font-style: italic;
}

.variants-section {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius);
  padding: 24px;
  margin-bottom: 24px;
}

.variants-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #fff;
}

.variants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.variant-pill {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-sm);
  padding: 12px 14px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.variant-pill:hover {
  border-color: var(--color-primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.15);
}

.variant-pill::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--color-primary);
  opacity: 0;
  transition: opacity var(--transition);
}

.variant-pill:hover::before { opacity: 1; }

.variant-pill.variant-unavailable {
  opacity: 0.45;
  filter: grayscale(0.4);
}

.variant-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.variant-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.variant-discount {
  font-size: 11px;
  font-weight: 700;
  background: rgba(252, 129, 129, 0.15);
  color: var(--color-red);
  padding: 1px 5px;
  border-radius: 4px;
}

.variant-original {
  font-size: 11px;
  color: var(--color-text-dim);
  text-decoration: line-through;
  margin-top: 2px;
}

.variant-sold-out {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-text-dim);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 1px 6px;
  margin-top: 4px;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

