/* ==========================================================================
   SHOPEE BIGSELLER™ ERP SUITE - DESIGN SYSTEM & STYLESHEET
   Curated for Kho Sỉ Ăn Vặt 1989 & Hien_Food (TP.HCM)
   ========================================================================== */

:root {
  --bg-primary: #0A0F1D;
  --bg-secondary: #10172A;
  --bg-surface: #162036;
  --bg-surface-hover: #1E2D4A;
  --bg-card: rgba(22, 32, 54, 0.85);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #EE4D2D;
  
  --shopee-orange: #EE4D2D;
  --shopee-orange-gradient: linear-gradient(135deg, #FF5722 0%, #EE4D2D 50%, #D32F2F 100%);
  --shopee-glow: rgba(238, 77, 45, 0.35);
  
  --color-emerald: #10B981;
  --color-emerald-bg: rgba(16, 185, 129, 0.12);
  --color-sky: #0EA5E9;
  --color-sky-bg: rgba(14, 165, 233, 0.12);
  --color-amber: #F59E0B;
  --color-amber-bg: rgba(245, 158, 11, 0.12);
  --color-purple: #8B5CF6;
  --color-purple-bg: rgba(139, 92, 246, 0.12);
  --color-rose: #F43F5E;
  --color-rose-bg: rgba(244, 63, 94, 0.12);

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(238, 77, 45, 0.25);
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-surface-hover);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--shopee-orange);
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */

.app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  width: 270px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
}

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

.sidebar-logo {
  width: 42px;
  height: 42px;
  background: var(--shopee-orange-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: var(--shadow-glow);
  color: white;
}

.brand-text h2 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, #FFF 0%, #CBD5E1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 10px;
  font-weight: 700;
  color: #EE4D2D;
  background: rgba(238, 77, 45, 0.15);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

/* STORE SELECTOR IN SIDEBAR */
.store-selector-box {
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color);
}

.store-selector-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.store-select-dropdown {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: var(--transition-fast);
}
.store-select-dropdown:focus {
  border-color: var(--shopee-orange);
}

/* SIDEBAR NAV MENU */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 8px 12px 4px;
  margin-top: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  border: 1px solid transparent;
}

.nav-item i {
  width: 18px;
  font-size: 15px;
  text-align: center;
  color: var(--text-muted);
  transition: var(--transition-fast);
}

.nav-item:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.nav-item:hover i {
  color: var(--shopee-orange);
}

.nav-item.active {
  background: rgba(238, 77, 45, 0.12);
  color: #FF7043;
  border-color: rgba(238, 77, 45, 0.3);
}

.nav-item.active i {
  color: #EE4D2D;
}

.nav-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg-surface-hover);
  color: var(--text-secondary);
}

.nav-badge.orange {
  background: var(--shopee-orange);
  color: white;
}

.nav-badge.emerald {
  background: var(--color-emerald);
  color: #064E3B;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.server-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-emerald);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-emerald);
  box-shadow: 0 0 8px var(--color-emerald);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* ==========================================================================
   MAIN CONTENT VIEWPORT
   ========================================================================== */

.main-viewport {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: radial-gradient(circle at top right, rgba(238, 77, 45, 0.04) 0%, transparent 60%);
}

/* TOP NAVBAR */
.top-navbar {
  height: 64px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(16, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  z-index: 40;
}

.nav-breadcrumb h3 {
  font-size: 16px;
  font-weight: 700;
}

.nav-breadcrumb p {
  font-size: 12px;
  color: var(--text-muted);
}

.top-navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: var(--shopee-orange-gradient);
  color: white;
  box-shadow: 0 2px 10px rgba(238, 77, 45, 0.3);
}
.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 15px rgba(238, 77, 45, 0.45);
}

.btn-secondary {
  background: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-primary);
}
.btn-secondary:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-emerald {
  background: var(--color-emerald);
  color: white;
}
.btn-emerald:hover {
  filter: brightness(1.1);
}

.btn-sky {
  background: var(--color-sky);
  color: white;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* TAB CONTENT CONTAINER */
.tab-viewport {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

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

/* ==========================================================================
   KPI SUMMARY CARDS
   ========================================================================== */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition-fast);
  backdrop-filter: blur(10px);
}
.kpi-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.kpi-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.kpi-card.orange .kpi-icon-wrap { background: rgba(238, 77, 45, 0.15); color: #FF7043; }
.kpi-card.emerald .kpi-icon-wrap { background: var(--color-emerald-bg); color: var(--color-emerald); }
.kpi-card.sky .kpi-icon-wrap { background: var(--color-sky-bg); color: var(--color-sky); }
.kpi-card.amber .kpi-icon-wrap { background: var(--color-amber-bg); color: var(--color-amber); }

.kpi-content {
  flex: 1;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 2px 0;
  letter-spacing: -0.5px;
}

.kpi-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ==========================================================================
   CARDS & SECTIONS
   ========================================================================== */

.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 24px;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-card);
}

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.card-title-group h4 {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title-group p {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ==========================================================================
   1-CLICK PRODUCT SCRAPER MODULE
   ========================================================================== */

.scraper-input-bar {
  display: flex;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  margin-bottom: 20px;
  transition: var(--transition-fast);
}
.scraper-input-bar:focus-within {
  border-color: var(--shopee-orange);
  box-shadow: 0 0 0 3px rgba(238, 77, 45, 0.15);
}

.scraper-input-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 14px;
  padding: 8px 12px;
}

.scraper-preview-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
}

.scraper-media-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
}

.canvas-frame-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.canvas-frame-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.frame-overlay-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--shopee-orange-gradient);
  color: white;
  font-size: 10.5px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  text-transform: uppercase;
}

.frame-overlay-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(0deg, rgba(238, 77, 45, 0.9) 0%, rgba(238, 77, 45, 0) 100%);
  padding: 16px 10px 8px;
  color: white;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.frame-selector-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.frame-chip {
  padding: 5px 10px;
  border-radius: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition-fast);
}
.frame-chip:hover, .frame-chip.active {
  border-color: var(--shopee-orange);
  color: #FF7043;
  background: rgba(238, 77, 45, 0.1);
}

.scraper-meta-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  font-family: inherit;
  transition: var(--transition-fast);
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--shopee-orange);
}

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

/* ==========================================================================
   DATA TABLES
   ========================================================================== */

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.custom-table th {
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.custom-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

.custom-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.product-row-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.product-thumb {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: #000;
  border: 1px solid var(--border-color);
}

/* STATUS BADGES */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.status-pill.orange { background: rgba(238, 77, 45, 0.15); color: #FF7043; border: 1px solid rgba(238, 77, 45, 0.3); }
.status-pill.emerald { background: var(--color-emerald-bg); color: var(--color-emerald); border: 1px solid rgba(16, 185, 129, 0.3); }
.status-pill.sky { background: var(--color-sky-bg); color: var(--color-sky); border: 1px solid rgba(14, 165, 233, 0.3); }
.status-pill.amber { background: var(--color-amber-bg); color: var(--color-amber); border: 1px solid rgba(245, 158, 11, 0.3); }

/* ==========================================================================
   AUTO-BUMP MARKETING WIDGET
   ========================================================================== */

.autobump-control-box {
  background: linear-gradient(135deg, rgba(238, 77, 45, 0.1) 0%, rgba(14, 165, 233, 0.05) 100%);
  border: 1px solid rgba(238, 77, 45, 0.3);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.autobump-timer-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
}

.timer-circle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid #EE4D2D;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #FF7043;
}

.timer-data h5 {
  font-size: 14px;
  font-weight: 700;
}

.timer-countdown {
  font-size: 18px;
  font-weight: 800;
  color: #EE4D2D;
  font-family: monospace;
}

/* ==========================================================================
   MODALS
   ========================================================================== */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

.modal-container {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.modal-container.large {
  max-width: 850px;
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
}
.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   A6 THERMAL PRINTING SHEET
   ========================================================================== */

.a6-label-sheet {
  width: 100mm;
  min-height: 145mm;
  background: white;
  color: black;
  padding: 8mm;
  border: 1px dashed #999;
  border-radius: 4px;
  margin: 0 auto 20px;
  font-family: Arial, sans-serif;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.a6-carrier-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid black;
  padding-bottom: 6px;
  margin-bottom: 6px;
}

.a6-carrier-name {
  font-size: 18px;
  font-weight: 900;
}

.a6-barcode-box {
  text-align: center;
  padding: 6px 0;
  border-bottom: 1px solid #333;
}

.a6-barcode-svg {
  width: 80%;
  height: 40px;
}

.a6-tracking-code {
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 1px;
}

.a6-address-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #333;
  font-size: 11px;
}

.a6-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 10.5px;
}

.a6-items-table th, .a6-items-table td {
  border: 1px solid #333;
  padding: 4px 6px;
}

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

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--shopee-orange);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideUp 0.3s ease-out;
}
.toast.emerald { border-left-color: var(--color-emerald); }
.toast.sky { border-left-color: var(--color-sky); }

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

@media print {
  body * {
    visibility: hidden;
  }
  .a6-label-sheet, .a6-label-sheet * {
    visibility: visible;
  }
  .a6-label-sheet {
    position: absolute;
    left: 0;
    top: 0;
    width: 100mm;
    height: 150mm;
    margin: 0;
    padding: 6mm;
    border: none;
    box-shadow: none;
  }
}
