/* ============================
   SHOPEE ADS ANALYZER
   Premium Dark Theme
   ============================ */

:root {
  --bg-primary: #0a0a1a;
  --bg-secondary: #0f0f2a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --bg-glass: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  --text-primary: #f0f0f5;
  --text-secondary: #8888aa;
  --text-muted: #555570;
  --cyan: #00d4ff;
  --purple: #8b5cf6;
  --green: #10b981;
  --orange: #f59e0b;
  --red: #ef4444;
  --pink: #ec4899;
  --blue: #3b82f6;
  --sidebar-width: 260px;
  --header-height: 60px;
  --radius: 14px;
  --radius-sm: 8px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  overflow-x: hidden;
  width: 100%;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
}

/* Animated background gradient */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(0, 212, 255, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(16, 185, 129, 0.04) 0%, transparent 60%);
  z-index: 0;
  pointer-events: none;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

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

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.logo-text {
  font-weight: 700;
  font-size: 1.1rem;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition);
}
.sidebar-toggle:hover { background: var(--bg-glass); color: var(--text-primary); }

/* Platform Tabs */
.platform-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 12px 4px;
}
.platform-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.platform-tab:hover { border-color: var(--text-muted); color: var(--text-primary); }
.platform-tab.active {
  background: linear-gradient(135deg, rgba(238,77,45,0.15), rgba(238,77,45,0.05));
  border-color: #ee4d2d;
  color: #ee4d2d;
  font-weight: 600;
}
.platform-tab.active[data-platform="tiktok"] {
  background: linear-gradient(135deg, rgba(255,0,80,0.15), rgba(0,242,234,0.08));
  border-color: #ff0050;
  color: #ff0050;
}
.platform-tab img { border-radius: 3px; }

/* Marketplace Picker (Add Store Modal) */
.marketplace-picker {
  display: flex;
  gap: 8px;
}
.marketplace-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}
.marketplace-option:hover { border-color: var(--text-muted); color: var(--text-primary); }
.marketplace-option.active {
  background: linear-gradient(135deg, rgba(238,77,45,0.15), rgba(238,77,45,0.05));
  border-color: #ee4d2d;
  color: #ee4d2d;
  font-weight: 600;
}
.marketplace-option.active[data-platform="tiktok"] {
  background: linear-gradient(135deg, rgba(255,0,80,0.15), rgba(0,242,234,0.08));
  border-color: #ff0050;
  color: #ff0050;
}

.sidebar-section {
  padding: 8px 12px;
}
.sidebar-section:last-of-type {
  flex: 1;
  overflow-y: auto;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}

.btn-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.btn-icon:hover {
  background: var(--cyan);
  color: white;
  border-color: var(--cyan);
  transform: scale(1.1);
}

.store-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.store-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.store-item:hover { background: var(--bg-glass); }
.store-item.active {
  background: rgba(0, 212, 255, 0.08);
}
.store-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  border-radius: 0 4px 4px 0;
  background: var(--cyan);
}

.store-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.store-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.store-count {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg-glass);
  padding: 2px 6px;
  border-radius: 10px;
}

/* Sidebar Upload History */
.sidebar-history-list {
  max-height: 200px;
  overflow-y: auto;
  padding: 0 12px;
}
.sidebar-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 4px;
  background: rgba(255,255,255,0.02);
  border: 1px solid transparent;
  transition: var(--transition);
}
.sidebar-history-item:hover {
  background: var(--bg-glass);
  border-color: var(--border);
}
.sh-info {
  flex: 1;
  min-width: 0;
}
.sh-name {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}
.sh-meta {
  font-size: 0.65rem;
  color: var(--text-muted);
}
.sh-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.sh-btn {
  width: 24px;
  height: 24px;
  border: none;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  transition: var(--transition);
  color: var(--text-secondary);
}
.sh-btn:hover {
  background: rgba(0, 212, 255, 0.1);
  color: var(--cyan);
}
.sh-btn-del:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
}

/* Sidebar Navigation Buttons */
.sidebar-nav-btn {
  width: calc(100% - 24px);
  margin: 2px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-nav-btn:hover { background: var(--bg-glass); color: var(--text-primary); }
.sidebar-nav-btn.active {
  background: linear-gradient(135deg, rgba(0,212,255,0.12), rgba(124,58,237,0.12));
  color: var(--cyan);
  font-weight: 600;
}

/* Upload Data View */
.upload-store-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
.upload-store-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}
.upload-store-tab:hover { border-color: var(--cyan); color: var(--text-primary); }
.upload-store-tab.active {
  background: linear-gradient(135deg, rgba(0,212,255,0.15), rgba(124,58,237,0.15));
  border-color: var(--cyan);
  color: var(--cyan);
  font-weight: 600;
}
.upload-store-tab .tab-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--cyan);
}

.upload-actions-row {
  display: flex;
  gap: 12px;
  margin: 20px 0;
}

.upload-history-section {
  margin-top: 32px;
}
.upload-history-section h3 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--text-primary);
}
.upload-history-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.history-row:hover { border-color: rgba(0,212,255,0.3); }
.history-row-info { flex: 1; min-width: 0; }
.history-row-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.history-row-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}
.history-row-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

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

.sidebar-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.sidebar-btn:hover { background: var(--bg-glass); color: var(--text-primary); }

/* Mobile Header */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: rgba(10, 10, 26, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 90;
  padding: 0 16px;
  align-items: center;
  gap: 12px;
}

.hamburger {
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}

.mobile-title {
  font-weight: 700;
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 95;
  backdrop-filter: blur(4px);
}

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

.view { animation: fadeIn 0.4s ease; }
.hidden { display: none !important; }

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

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  text-align: center;
  gap: 16px;
}

.empty-icon {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(0,212,255,0.1), rgba(139,92,246,0.1));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--cyan);
  margin-bottom: 8px;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(0,212,255,0.2); }
  50% { transform: scale(1.05); box-shadow: 0 0 30px 10px rgba(0,212,255,0.1); }
}

.empty-state h2 {
  font-size: 1.8rem;
  font-weight: 700;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  color: white;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 212, 255, 0.3);
}

.btn-glow {
  box-shadow: 0 4px 15px rgba(0, 212, 255, 0.2);
}
.btn-glow:hover {
  box-shadow: 0 8px 30px rgba(0, 212, 255, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-outline {
  background: transparent;
  color: var(--cyan);
  border: 1px dashed var(--border);
}
.btn-outline:hover {
  border-color: var(--cyan);
  background: rgba(0, 212, 255, 0.05);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* View Header */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.view-title {
  font-size: 1.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-primary), var(--cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.view-subtitle {
  color: var(--text-secondary);
  margin-top: 4px;
  font-size: 0.9rem;
}

/* ============================
   PERIOD FILTER BAR
   ============================ */
.period-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
}

.period-tabs {
  display: flex;
  gap: 4px;
}

.period-tab {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.period-tab:hover {
  background: var(--bg-glass);
  color: var(--text-primary);
}
.period-tab.active {
  background: rgba(0, 212, 255, 0.1);
  color: var(--cyan);
  border-color: rgba(0, 212, 255, 0.25);
}

.period-select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.period-select-wrap .select-input {
  min-width: 200px;
  max-width: 100%;
}

/* ============================
   UPLOAD ZONE
   ============================ */
.upload-zone {
  margin-bottom: 28px;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 300px; }
}

.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.upload-area::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(0,212,255,0.02), rgba(139,92,246,0.02));
  transition: var(--transition);
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--cyan);
  background: rgba(0, 212, 255, 0.03);
}
.upload-area.dragover {
  transform: scale(1.01);
  box-shadow: 0 0 40px rgba(0, 212, 255, 0.1);
}

.upload-icon {
  color: var(--cyan);
  margin-bottom: 16px;
  opacity: 0.8;
}

.upload-area h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.upload-area p {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.upload-formats {
  margin-top: 8px !important;
  color: var(--text-muted) !important;
  font-size: 0.75rem !important;
}

.upload-progress {
  padding: 24px;
  text-align: center;
}

.progress-bar {
  height: 4px;
  background: var(--bg-glass);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan), var(--purple));
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s ease;
  animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.progress-text {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

/* ============================
   SUMMARY CARDS
   ============================ */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition);
  backdrop-filter: blur(10px);
}

.summary-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.summary-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.summary-icon.cyan { background: rgba(0,212,255,0.12); color: var(--cyan); }
.summary-icon.green { background: rgba(16,185,129,0.12); color: var(--green); }
.summary-icon.purple { background: rgba(139,92,246,0.12); color: var(--purple); }
.summary-icon.orange { background: rgba(245,158,11,0.12); color: var(--orange); }
.summary-icon.blue { background: rgba(59,130,246,0.12); color: var(--blue); }
.summary-icon.pink { background: rgba(236,72,153,0.12); color: var(--pink); }

.summary-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
}

/* ============================
   CHARTS
   ============================ */
.charts-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  backdrop-filter: blur(10px);
}

.chart-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

/* ============================
   PRODUCTS SECTION
   ============================ */
.products-section { margin-bottom: 28px; }

/* Category Tabs */
.product-category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.category-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}
.category-tab:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}
.category-tab.active {
  background: rgba(0, 212, 255, 0.08);
  border-color: rgba(0, 212, 255, 0.3);
  color: var(--cyan);
}
.cat-icon { font-size: 0.9rem; }
.cat-label { font-size: inherit; }
.cat-count {
  background: rgba(255,255,255,0.08);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}
.category-tab.active .cat-count {
  background: rgba(0, 212, 255, 0.15);
  color: var(--cyan);
}

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

.products-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.products-filter {
  display: flex;
  gap: 8px;
}

.select-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}
.select-input:hover, .select-input:focus {
  border-color: var(--cyan);
}
.select-input option {
  background: var(--bg-secondary);
}

.products-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Product Card */
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  backdrop-filter: blur(10px);
}
.product-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.product-main {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  cursor: pointer;
}

.product-score {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
  position: relative;
}
.product-score.excellent { background: rgba(16,185,129,0.15); color: var(--green); border: 1px solid rgba(16,185,129,0.3); }
.product-score.good { background: rgba(0,212,255,0.15); color: var(--cyan); border: 1px solid rgba(0,212,255,0.3); }
.product-score.average { background: rgba(245,158,11,0.15); color: var(--orange); border: 1px solid rgba(245,158,11,0.3); }
.product-score.poor { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }

.product-info {
  flex: 1;
  min-width: 0;
}

.product-name {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.product-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.meta-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
}
.meta-dot.active { background: var(--green); }
.meta-dot.paused { background: var(--orange); }
.meta-dot.ended { background: var(--red); }

.product-stats {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-shrink: 0;
}

.stat-item {
  text-align: right;
}

.stat-label {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
}
.stat-value.positive { color: var(--green); }
.stat-value.negative { color: var(--red); }
.stat-value.neutral { color: var(--orange); }

.product-expand {
  color: var(--text-muted);
  transition: var(--transition);
  flex-shrink: 0;
}
.product-card.expanded .product-expand { transform: rotate(180deg); }

/* Product Profit Badge */
.product-profit-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  min-width: 80px;
}
.profit-badge-icon {
  font-size: 0.75rem;
}
.profit-badge-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.7;
}
.profit-badge-value {
  font-weight: 700;
  font-size: 0.85rem;
}

/* Warning state for low-profit products */
.product-card.product-warning {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.03);
}
.product-card.product-warning:hover {
  border-color: rgba(239, 68, 68, 0.4);
}

/* Product Details (expandable) */
.product-details {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.product-card.expanded .product-details {
  max-height: 800px;
}

.details-content {
  padding: 0 20px 20px;
  border-top: 1px solid var(--border);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding-top: 16px;
}

.detail-item {
  background: rgba(255,255,255,0.02);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.detail-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.detail-value {
  font-weight: 600;
  font-size: 0.95rem;
}

/* Recommendation */
.recommendation {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.85rem;
  line-height: 1.5;
}
.recommendation.scale-up {
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.2);
  color: var(--green);
}
.recommendation.optimize {
  background: rgba(0,212,255,0.08);
  border: 1px solid rgba(0,212,255,0.2);
  color: var(--cyan);
}
.recommendation.warning {
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  color: var(--orange);
}
.recommendation.danger {
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  color: var(--red);
}

.recommendation-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* HPP / Profit section in card */
.profit-section {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.15);
}

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

.profit-header span {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-hpp {
  padding: 4px 10px;
  font-size: 0.75rem;
  background: rgba(139,92,246,0.15);
  border: 1px solid rgba(139,92,246,0.3);
  color: var(--purple);
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: var(--transition);
}
.btn-hpp:hover {
  background: var(--purple);
  color: white;
}

.profit-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.profit-item {
  text-align: center;
}

.profit-item-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}

.profit-item-value {
  font-weight: 700;
  font-size: 0.95rem;
}

/* ============================
   HISTORY
   ============================ */
.history-section {
  margin-top: 32px;
}

.history-section h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.history-item:hover {
  background: var(--bg-card-hover);
}

.history-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-filename {
  font-weight: 500;
  font-size: 0.85rem;
}

.history-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ============================
   MODALS
   ============================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.2s ease;
  padding: 20px;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  animation: modalSlide 0.3s ease;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

.modal-lg {
  max-width: 600px;
}

@keyframes modalSlide {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal.modal-xl {
  max-width: 900px;
  width: 95%;
}

/* Bulk HPP Modal */
.bulk-hpp-mass {
  margin-bottom: 20px;
  padding: 16px;
  background: rgba(0, 212, 255, 0.04);
  border: 1px solid rgba(0, 212, 255, 0.12);
  border-radius: var(--radius-sm);
}

.mass-hpp-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.mass-hpp-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 12px;
}

.bulk-hpp-list {
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bulk-hpp-item {
  display: grid;
  grid-template-columns: 1fr 100px 120px 120px;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}
.bulk-hpp-item:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.bulk-hpp-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bulk-hpp-name .meta-tag {
  display: block;
  margin-top: 2px;
}

.bulk-hpp-status {
  font-size: 0.75rem;
  text-align: center;
}

.bulk-hpp-sold {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
}

.bulk-hpp-input {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 6px 10px;
  font-family: inherit;
  font-size: 0.85rem;
  width: 100%;
  outline: none;
  transition: var(--transition);
  text-align: right;
}
.bulk-hpp-input:focus {
  border-color: var(--cyan);
}
.bulk-hpp-input.has-value {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.05);
}

.bulk-hpp-profit {
  font-size: 0.8rem;
  font-weight: 600;
  text-align: right;
  min-width: 100px;
}
.bulk-hpp-profit.positive { color: var(--green); }
.bulk-hpp-profit.negative { color: var(--red); }

.bulk-hpp-header {
  display: grid;
  grid-template-columns: 1fr 100px 120px 120px;
  gap: 12px;
  padding: 6px 14px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.btn-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.btn-close:hover { background: var(--bg-glass); color: var(--text-primary); }

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

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

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.text-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition);
  outline: none;
}
.text-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.1);
}
.text-input::placeholder { color: var(--text-muted); }

.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-option {
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
}
.color-option:hover { transform: scale(1.15); }
.color-option.active {
  border-color: white;
  box-shadow: 0 0 12px currentColor;
}

/* HPP Preview */
.hpp-product-name {
  font-weight: 600;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.hpp-preview {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.hpp-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.85rem;
}

.hpp-row span:first-child { color: var(--text-secondary); }
.hpp-row span:last-child { font-weight: 600; }
.hpp-row.divider { border-top: 1px dashed var(--border); padding-top: 10px; margin-top: 4px; }
.hpp-row.total span:last-child { color: var(--green); font-size: 1.1rem; }
.hpp-row.total span:last-child.negative { color: var(--red); }

/* Settings Store Items */
.settings-store-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: var(--transition);
}
.settings-store-item:hover { background: var(--bg-card-hover); }

.settings-store-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.settings-store-name {
  flex: 1;
  font-weight: 500;
}

.settings-store-actions {
  display: flex;
  gap: 6px;
}

/* ============================
   TOAST
   ============================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.3s ease;
}

.toast.success { border-color: rgba(16,185,129,0.3); }
.toast.success .toast-icon { color: var(--green); }
.toast.error { border-color: rgba(239,68,68,0.3); }
.toast.error .toast-icon { color: var(--red); }
.toast.info { border-color: rgba(0,212,255,0.3); }
.toast.info .toast-icon { color: var(--cyan); }

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

.toast-out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(20px); }
}

.toast-icon { font-size: 1.1rem; }

/* ============================
   RESPONSIVE
   ============================ */

/* Tablet */
@media (max-width: 1024px) {
  .summary-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .charts-section {
    grid-template-columns: 1fr;
  }
  .bulk-hpp-item {
    grid-template-columns: 1fr 80px 100px 100px;
    gap: 8px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-header {
    display: flex;
  }

  .main {
    margin-left: 0;
    padding: 76px 12px 24px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .view-header {
    flex-direction: column;
    gap: 12px;
  }

  .view-title {
    font-size: 1.4rem;
  }

  .view-actions {
    width: 100%;
    display: flex;
    gap: 8px;
  }
  .view-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 10px 12px;
    font-size: 0.8rem;
  }

  /* Period filter bar mobile */
  .period-filter-bar {
    flex-direction: column;
    gap: 10px;
    padding: 10px;
  }
  .period-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
  }
  .period-tab {
    padding: 6px 10px;
    font-size: 0.75rem;
    flex-shrink: 0;
  }
  .period-select-wrap {
    width: 100%;
  }
  .period-select-wrap .select-input {
    min-width: 0;
    flex: 1;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .summary-card {
    padding: 14px;
    gap: 10px;
  }
  .summary-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
  }
  .summary-value {
    font-size: 1rem;
  }

  .charts-section {
    grid-template-columns: 1fr;
  }

  .product-stats {
    display: none;
  }

  .product-profit-badge {
    flex-direction: row;
    gap: 4px;
    padding: 4px 10px;
    min-width: auto;
  }
  .profit-badge-label {
    display: none;
  }

  .product-main {
    padding: 12px 14px;
    gap: 10px;
  }
  .product-score {
    width: 40px; height: 40px;
    font-size: 0.95rem;
    border-radius: 10px;
  }
  .product-name {
    font-size: 0.85rem;
  }

  .products-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .products-filter {
    width: 100%;
  }
  .select-input {
    flex: 1;
  }

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

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

  /* Modal mobile */
  .modal {
    width: 95% !important;
    max-width: 95% !important;
    max-height: 90vh;
    overflow-y: auto;
  }
  .modal.modal-xl {
    width: 98% !important;
    max-width: 98% !important;
  }
  .bulk-hpp-item {
    grid-template-columns: 1fr 60px 90px;
    gap: 6px;
    padding: 8px 10px;
  }
  .bulk-hpp-profit {
    display: none;
  }
  .bulk-hpp-header {
    grid-template-columns: 1fr 60px 90px;
  }
  .bulk-hpp-header span:last-child {
    display: none;
  }
  .mass-hpp-row {
    flex-direction: column;
    gap: 8px;
  }
  .mass-hpp-row .btn {
    width: 100%;
    justify-content: center;
  }

  /* History mobile */
  .history-item {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
}

/* Small phone */
@media (max-width: 480px) {
  .main {
    padding: 72px 10px 20px;
  }
  .summary-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .summary-card {
    padding: 12px 14px;
  }
  .details-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .view-title {
    font-size: 1.2rem;
  }
  .period-tab {
    padding: 5px 8px;
    font-size: 0.7rem;
  }
}
