:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --accent: #0ea5e9;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --radius: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.header-top {
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

/* Multi-Vendor Nav Bar */
.source-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px;
  background: #f8fafc;
  border-top: 1px solid var(--border-light);
  gap: 16px;
  flex-wrap: wrap;
}

.source-tabs {
  display: flex;
  gap: 8px;
  align-items: center;
}

.source-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: #ffffff;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}

.source-tab:hover {
  background: #f1f5f9;
  color: var(--text-main);
}

.source-tab.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.source-tab.highlight.active {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  border-color: #6d28d9;
  color: #ffffff;
}

.source-tab .tab-count {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.08);
}

.source-tab.active .tab-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.stats-banner {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.stats-banner strong {
  color: var(--text-main);
}


.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.logo-text h1 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.2;
}

.logo-text span {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Search Bar */
.search-wrapper {
  flex: 1;
  max-width: 650px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 12px 18px 12px 46px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--bg-main);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 16px;
}

.search-clear {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

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

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

.currency-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.sync-btn {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.2);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.sync-btn:hover {
  background: var(--primary);
  color: white;
}

/* Layout */
.app-container {
  display: flex;
  flex: 1;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  padding: 24px;
  gap: 24px;
}

/* Sidebar */
.sidebar {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.filter-card {
  background: #ffffff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.btn-reset-filters {
  background: #ffffff;
  border: 1px solid #fca5a5;
  color: #ef4444;
  font-weight: 600;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.btn-reset-filters:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

.price-range-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.price-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  width: 100%;
}

.price-input:focus {
  border-color: var(--primary);
}

.price-dash {
  color: var(--text-muted);
}

.btn-apply-price {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-apply-price:hover {
  background: var(--primary-hover);
}

.category-filter-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 4px;
}

.filter-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}


/* Category Tree */
.category-tree {
  list-style: none;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 6px;
}

.category-item {
  margin-bottom: 4px;
}

.category-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.15s;
}

.category-btn:hover {
  background: var(--bg-main);
  color: var(--primary);
}

.category-btn.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.category-badge {
  font-size: 11px;
  padding: 2px 6px;
  background: #f1f5f9;
  border-radius: 10px;
  color: var(--text-muted);
}

/* Vendor List */
.vendor-search-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
  margin-bottom: 10px;
  outline: none;
}

.vendor-list {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.vendor-list::-webkit-scrollbar {
  width: 5px;
}
.vendor-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.vendor-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  background: #ffffff;
  transition: all 0.15s ease;
  user-select: none;
}

.vendor-item:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
  transform: translateX(2px);
}

.vendor-item.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
  font-weight: 600;
}

.vendor-name {
  font-size: 13px;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.vendor-item.active .vendor-name {
  color: #1d4ed8;
  font-weight: 600;
}

.vendor-count {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 12px;
  background: #f1f5f9;
  color: #64748b;
  flex-shrink: 0;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.vendor-item:hover .vendor-count {
  background: #e2e8f0;
  color: #334155;
}

.vendor-item.active .vendor-count {
  background: #2563eb;
  color: #ffffff;
}


/* Stock Toggle */
.stock-toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #cbd5e1;
  transition: .2s;
  border-radius: 22px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .2s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(18px);
}

/* Main Area */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.toolbar {
  background: #ffffff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
  gap: 12px;
}

.results-info {
  font-size: 14px;
  color: var(--text-muted);
}

.results-info strong {
  color: var(--text-main);
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sort-select {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.view-toggle {
  display: flex;
  background: var(--bg-main);
  border-radius: 8px;
  padding: 2px;
  border: 1px solid var(--border);
}

.view-btn {
  background: none;
  border: none;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
}

.view-btn.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Active Filter Chips */
.active-filters,
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.filter-chip {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.05);
  animation: fadeInChip 0.2s ease;
}

@keyframes fadeInChip {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.filter-chip .chip-close,
.filter-chip-remove {
  cursor: pointer;
  color: #93c5fd;
  font-size: 11px;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: 50%;
}

.filter-chip .chip-close:hover,
.filter-chip-remove:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}


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

.product-card {
  background: #ffffff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  position: relative;
}

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

.product-image-container {
  height: 180px;
  background: #f8fafc;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  overflow: hidden;
  position: relative;
}

.product-image {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  transition: transform 0.2s;
}

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

.product-image-placeholder {
  color: var(--text-light);
  font-size: 42px;
}

.stock-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.stock-in {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.stock-out {
  background: #f1f5f9;
  color: var(--text-muted);
}

.product-vendor {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.product-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.35;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 38px;
}

.product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.product-articul {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
}

.product-pricing {
  margin-top: auto;
  border-top: 1px solid var(--border-light);
  padding-top: 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}

.price-main {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.price-unit {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

.price-rrp {
  font-size: 11px;
  color: var(--text-light);
  text-decoration: line-through;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-detail {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-detail:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

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

.page-btn {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

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

.page-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

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

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #ffffff;
  border-radius: 16px;
  max-width: 850px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  position: relative;
  transform: scale(0.96);
  transition: transform 0.2s ease;
}

.modal-overlay.open .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 10;
}

.modal-close {
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.modal-body {
  padding: 24px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.modal-gallery {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-main-img {
  width: 100%;
  height: 280px;
  background: #f8fafc;
  border-radius: 12px;
  object-fit: contain;
  padding: 12px;
  border: 1px solid var(--border);
}

.modal-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}

.modal-thumb {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: contain;
  cursor: pointer;
  padding: 4px;
  background: #f8fafc;
}

.modal-thumb.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

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

.specs-table tr {
  border-bottom: 1px solid var(--border-light);
}

.specs-table th {
  text-align: left;
  padding: 8px 0;
  color: var(--text-muted);
  font-weight: 500;
  width: 45%;
}

.specs-table td {
  padding: 8px 0;
  font-weight: 600;
  color: var(--text-main);
}

/* Responsive */
@media (max-width: 900px) {
  .app-container {
    flex-direction: column;
    padding: 14px;
  }
  .sidebar {
    width: 100%;
  }
  .modal-body {
    grid-template-columns: 1fr;
  }
}

/* Multi-Vendor Badges */
.badge-source {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  z-index: 2;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 4px;
}

.badge-source-both {
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #ffffff;
}

.badge-source-treolan {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.badge-source-netlab {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.savings-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #059669;
  background: #d1fae5;
  padding: 2px 7px;
  border-radius: 4px;
  margin-top: 4px;
}

.compare-pricing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #f8fafc;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  margin-top: 8px;
  font-size: 11px;
}

.compare-supplier-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.compare-supplier-name {
  font-weight: 600;
  color: var(--text-muted);
}

.compare-supplier-price {
  font-weight: 700;
  font-size: 12px;
}

.compare-supplier-price.best {
  color: #059669;
}

.compare-supplier-price.other {
  color: #94a3b8;
  text-decoration: line-through;
}

.modal-compare-card {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}

.modal-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 10px;
}

.modal-supplier-col {
  background: #ffffff;
  border-radius: 8px;
  padding: 12px;
  border: 1px solid var(--border-light);
}

.modal-supplier-col.winner {
  border-color: #10b981;
  box-shadow: 0 0 0 1px #10b981;
}

/* Category Macro Tabs Bar */
.category-tabs-bar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 8px 24px;
  overflow: hidden;
}
.cat-tabs-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 2px;
  align-items: center;
}
.cat-tabs-scroll::-webkit-scrollbar {
  height: 4px;
}
.cat-tabs-scroll::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.cat-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.cat-tab-btn i {
  color: #2563eb;
  font-size: 13px;
}
.cat-tab-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}
.cat-tab-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.cat-tab-btn.active i {
  color: #ffffff;
}
.cat-tab-btn .cat-count {
  font-size: 11px;
  background: rgba(0, 0, 0, 0.08);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 2px;
}
.cat-tab-btn.active .cat-count {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* Sidebar mini category tabs */
.sidebar-cat-tabs {
  display: flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
  margin-bottom: 10px;
  gap: 4px;
}
.sidebar-cat-tab {
  flex: 1;
  padding: 5px 8px;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.sidebar-cat-tab.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ==========================================================================
   CART & CHECKOUT SYSTEM STYLES
   ========================================================================== */

/* Header Cart Button */
.header-cart-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #2563eb;
  color: #ffffff;
  border: none;
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  position: relative;
}
.header-cart-btn:hover {
  background: #1d4ed8;
  transform: translateY(-1px);
}
.header-cart-badge {
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  height: 20px;
  min-width: 20px;
  padding: 0 5px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Cart Overlay */
.cart-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}
.cart-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Cart Drawer */
.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 520px;
  max-width: 100vw;
  height: 100%;
  background: #ffffff;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}
.cart-drawer.open {
  transform: translateX(0);
}

.cart-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.cart-drawer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
}
.drawer-count-badge {
  background: #2563eb;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}
.cart-drawer-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #64748b;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s;
}
.cart-drawer-close:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.cart-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

/* Cart Empty State */
.cart-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #64748b;
}
.cart-empty-state h3 {
  font-size: 18px;
  color: #0f172a;
  margin-bottom: 8px;
}
.cart-empty-state p {
  font-size: 14px;
  line-height: 1.5;
}

/* Cart Items */
.cart-items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 12px;
}
.btn-clear-cart {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.btn-clear-cart:hover {
  background: #fee2e2;
}

.cart-item-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}
.cart-item-thumb {
  width: 56px;
  height: 56px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 2px;
}
.cart-item-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.cart-item-placeholder {
  color: #94a3b8;
  font-size: 24px;
}
.cart-item-info {
  flex: 1;
  min-width: 0;
}
.cart-item-title {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.cart-item-meta {
  font-size: 11px;
  color: #64748b;
  display: flex;
  gap: 8px;
  margin-bottom: 2px;
}
.cart-item-price-unit {
  font-size: 11px;
  color: #64748b;
}

.cart-item-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.qty-control {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  overflow: hidden;
}
.qty-btn {
  border: none;
  background: none;
  width: 26px;
  height: 26px;
  font-size: 14px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.qty-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}
.qty-input {
  width: 32px;
  height: 26px;
  border: none;
  background: #ffffff;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
  padding: 0;
  -moz-appearance: textfield;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}
.cart-item-line-total {
  font-size: 13px;
  font-weight: 800;
  color: #0f172a;
  min-width: 70px;
  text-align: right;
}
.btn-remove-item {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  font-size: 13px;
  border-radius: 4px;
  transition: all 0.2s;
}
.btn-remove-item:hover {
  color: #ef4444;
  background: #fee2e2;
}

/* Cart Summary */
.cart-summary-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 16px 0;
}
.summary-line {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #64748b;
  margin-bottom: 6px;
}
.summary-line.total-line {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}
.summary-line.total-line .total-price {
  color: #2563eb;
  font-size: 18px;
}

/* Checkout Form */
.checkout-form-box {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px;
  margin-top: 16px;
}
.checkout-form-title {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.checkout-form-subtitle {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 14px;
}
.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 4px;
}
.form-group label .required {
  color: #ef4444;
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: #0f172a;
  background: #ffffff;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.form-control:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.btn-submit-order {
  width: 100%;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border: none;
  padding: 13px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  margin-top: 8px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}
.btn-submit-order:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
}

/* Success Box */
.order-success-box {
  text-align: center;
  padding: 30px 10px;
}
.success-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #dcfce7;
  color: #10b981;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  margin-bottom: 16px;
}
.order-success-box h2 {
  font-size: 20px;
  color: #0f172a;
  margin-bottom: 10px;
}
.order-number-badge {
  display: inline-block;
  background: #eff6ff;
  color: #2563eb;
  font-family: 'JetBrains Mono', monospace, monospace;
  font-size: 18px;
  font-weight: 800;
  padding: 6px 16px;
  border-radius: 8px;
  border: 1px dashed #93c5fd;
  margin-bottom: 16px;
}

/* Floating Toast */
.cart-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  font-weight: 500;
  z-index: 10000;
  transform: translateY(120px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.cart-toast.visible {
  transform: translateY(0);
  opacity: 1;
}
.btn-toast-cart {
  background: #2563eb;
  color: #ffffff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn-toast-cart:hover {
  background: #1d4ed8;
}

/* ==========================================================================
   HIERARCHICAL CATEGORY TREE STYLES (DNS / CITILINK STYLE)
   ========================================================================== */
/* ==========================================================================
   ENHANCED CATEGORY SIDEBAR & USER-FRIENDLY FILTERS
   ========================================================================== */

/* Category Search Box */
.cat-search-box {
  position: relative;
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.cat-search-icon {
  position: absolute;
  left: 11px;
  color: #94a3b8;
  font-size: 13px;
  pointer-events: none;
}

.cat-search-input {
  width: 100%;
  padding: 8px 32px 8px 32px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s ease;
}

.cat-search-input:focus {
  background: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.cat-search-clear {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.cat-search-clear:hover {
  color: #ef4444;
}

/* Category Filter List */
.category-filter-list {
  max-height: 440px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.category-filter-list::-webkit-scrollbar {
  width: 5px;
}
.category-filter-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

/* Modern Category Filter Row (Used for both Popular & Flat) */
.cat-filter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  background: #ffffff;
  transition: all 0.15s ease;
  user-select: none;
}

.cat-filter-item:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
  transform: translateX(2px);
}

.cat-filter-item.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.08);
}

.cat-item-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.cat-icon-wrap {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.cat-filter-item:hover .cat-icon-wrap {
  transform: scale(1.08);
}

.cat-name {
  font-size: 13px;
  color: #334155;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.cat-filter-item.active .cat-name {
  color: #1d4ed8;
  font-weight: 600;
}

/* Count Badge */
.cat-count-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 12px;
  background: #f1f5f9;
  color: #64748b;
  flex-shrink: 0;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.cat-filter-item:hover .cat-count-badge {
  background: #e2e8f0;
  color: #334155;
}

.cat-filter-item.active .cat-count-badge {
  background: #2563eb;
  color: #ffffff;
}

.cat-count-badge.sm {
  font-size: 10px;
  padding: 1px 6px;
}

/* Category Tree Accordion */
.cat-tree-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.cat-tree-node {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
  transition: all 0.2s ease;
}

.cat-tree-node.expanded {
  border-color: #93c5fd;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.06);
}

.cat-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  cursor: pointer;
  background: #ffffff;
  transition: background 0.15s ease;
  user-select: none;
}

.cat-tree-header:hover {
  background: #f8fafc;
}

.cat-tree-header.active-macro {
  background: #eff6ff;
  border-left: 3px solid #2563eb;
}

.cat-tree-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.cat-tree-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cat-tree-arrow {
  font-size: 11px;
  color: #94a3b8;
  transition: transform 0.2s ease;
  margin-left: 2px;
}

.cat-tree-node.expanded .cat-tree-arrow {
  transform: rotate(90deg);
  color: #2563eb;
}

.cat-tree-children {
  display: none;
  padding: 6px 6px 8px 14px;
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
}

.cat-tree-node.expanded .cat-tree-children {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cat-tree-subitem {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.cat-tree-subitem:hover {
  background: #e2e8f0;
  color: #0f172a;
  transform: translateX(2px);
}

.cat-tree-subitem.active {
  background: #2563eb;
  color: #ffffff;
  font-weight: 600;
}

.cat-tree-subitem.active .cat-count-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.cat-sub-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Sidebar Tab Switcher */
.sidebar-cat-tabs {
  display: flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 10px;
  margin-bottom: 12px;
  gap: 3px;
}

.sidebar-cat-tab {
  flex: 1;
  padding: 7px 10px;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-cat-tab:hover {
  color: #1e293b;
}

.sidebar-cat-tab.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}


/* Card Button: Add to Cart */
.btn-add-cart {
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}
.btn-add-cart:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}
.btn-add-cart.in-cart {
  background: #dcfce7;
  border-color: #86efac;
  color: #15803d;
}

/* ============================================================
   AI HARDWARE CONSULTANT WIDGET
   ============================================================ */
.ai-launcher-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #ffffff;
  border: none;
  border-radius: 50px;
  padding: 10px 20px 10px 12px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.35);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.ai-launcher-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.45);
}
.ai-launcher-btn.active {
  background: #1e293b;
  box-shadow: 0 8px 20px rgba(0,0,0,0.25);
}
.ai-launcher-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  backdrop-filter: blur(4px);
}
.ai-launcher-label {
  display: flex;
  flex-direction: column;
  text-align: left;
}
.ai-label-title {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}
.ai-label-sub {
  font-size: 11px;
  opacity: 0.85;
}
.ai-online-ping {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
  animation: pulse-green 2s infinite;
}
@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Chat Window */
.ai-chat-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 450px;
  height: 640px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.06);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ai-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes ai-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.ai-chat-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ai-chat-header-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ai-header-avatar {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.ai-status-indicator {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #2563eb;
}
.ai-header-title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
}
.ai-header-subtitle {
  font-size: 11px;
  opacity: 0.85;
}
.ai-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-header-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.2s;
}
.ai-header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Messages Area */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f8fafc;
  scroll-behavior: smooth;
}
.ai-message {
  display: flex;
  flex-direction: column;
  max-width: 92%;
  animation: ai-msg-in 0.25s ease;
}
@keyframes ai-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.ai-message-user {
  align-self: flex-end;
}
.ai-message-user .ai-message-bubble {
  background: #2563eb;
  color: #ffffff;
  border-radius: 16px 16px 4px 16px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.5;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}
.ai-message-assistant {
  align-self: flex-start;
  width: 100%;
}
.ai-message-assistant .ai-message-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-radius: 16px 16px 16px 4px;
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Markdown elements inside assistant message */
.ai-message-body p {
  margin: 0 0 10px 0;
}
.ai-message-body p:last-child {
  margin-bottom: 0;
}
.ai-message-body strong {
  color: #0f172a;
}
.ai-message-body ul {
  margin: 6px 0 10px 18px;
  padding: 0;
}
.ai-message-body li {
  margin-bottom: 4px;
}
.ai-p-spacer {
  height: 8px;
}
.ai-table-wrap {
  overflow-x: auto;
  margin: 10px 0;
}
.ai-chat-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.ai-chat-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f1f5f9;
}

/* Product Mini-Cards inside Assistant Message */
.ai-products-deck {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}
.ai-products-deck-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-products-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-mini-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  transition: all 0.2s;
}
.ai-mini-card:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}
.ai-mini-thumb {
  width: 52px;
  height: 52px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.ai-mini-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.ai-mini-placeholder {
  color: #94a3b8;
  font-size: 18px;
}
.ai-mini-content {
  flex: 1;
  min-width: 0;
}
.ai-mini-title {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.ai-mini-title:hover {
  color: #2563eb;
  text-decoration: underline;
}
.ai-mini-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #64748b;
  margin-bottom: 4px;
}
.ai-mini-wh {
  background: #e2e8f0;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}
.ai-mini-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-mini-price {
  font-size: 14px;
  font-weight: 800;
  color: #2563eb;
}
.ai-mini-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.btn-mini-cart {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}
.btn-mini-cart:hover {
  background: #1d4ed8;
}
.btn-mini-view {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 7px;
  font-size: 11px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-mini-view:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Action Buttons (Filter Catalog) */
.ai-actions-row {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ai-action-btn {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}
.ai-action-btn:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

/* Suggested Quick Reply Chips */
.ai-suggestions-row {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ai-chip-btn {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.ai-chip-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1e40af;
  transform: translateY(-1px);
}

/* Typing Indicator */
.ai-typing-indicator {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
}
.ai-typing-dots {
  display: flex;
  gap: 4px;
}
.ai-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2563eb;
  animation: ai-bounce 1.4s infinite ease-in-out both;
}
.ai-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes ai-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
.ai-typing-text {
  font-size: 12px;
  color: #64748b;
  font-style: italic;
}

/* Input Form */
.ai-chat-form {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.ai-chat-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 13.5px;
  outline: none;
  transition: all 0.2s;
}
.ai-chat-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.ai-chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.ai-chat-send-btn:hover {
  background: #1d4ed8;
  transform: scale(1.05);
}
.ai-chat-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
  .ai-chat-window {
    right: 12px;
    left: 12px;
    bottom: 80px;
    width: auto;
    height: calc(100vh - 100px);
    max-height: none;
    border-radius: 16px;
  }
  .ai-launcher-label {
    display: none;
  }
  .ai-launcher-btn {
    padding: 8px;
    border-radius: 50%;
    bottom: 16px;
    right: 16px;
  }
}

/* AI Inline links & Mini title buttons */
.ai-mini-title-btn {
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  width: 100%;
  margin-bottom: 3px;
  transition: color 0.15s;
}
.ai-mini-title-btn:hover {
  color: #2563eb;
  text-decoration: underline;
}

.ai-inline-product-link {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: 2px 0;
  text-decoration: none;
  transition: all 0.2s;
}
.ai-inline-product-link:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

/* AI Action Button: Checkout */
.ai-action-btn-checkout {
  background: linear-gradient(135deg, #059669, #10b981) !important;
  color: #ffffff !important;
  border-color: #059669 !important;
  font-weight: 700 !important;
  box-shadow: 0 3px 8px rgba(16, 185, 129, 0.25);
}
.ai-action-btn-checkout:hover {
  background: linear-gradient(135deg, #047857, #059669) !important;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
  transform: translateY(-1px);
}

/* ============================================================
   AI PRODUCT QUICK VIEW MODAL (On-page overlay)
   ============================================================ */
.ai-qv-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(5px);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: ai-fade-in 0.2s ease;
}
@keyframes ai-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ai-qv-content {
  background: #ffffff;
  border-radius: 20px;
  width: 900px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  position: relative;
  animation: ai-scale-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes ai-scale-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.ai-qv-header {
  padding: 18px 24px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #ffffff;
  z-index: 10;
}
.ai-qv-header-info {
  flex: 1;
  min-width: 0;
  padding-right: 16px;
}
.ai-qv-badge {
  display: inline-block;
  background: #eff6ff;
  color: #2563eb;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.ai-qv-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.35;
}
.ai-qv-close-btn {
  background: #f1f5f9;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.ai-qv-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.ai-qv-body {
  padding: 24px;
}
.ai-qv-loading {
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: #64748b;
  font-size: 14px;
}

.ai-qv-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 28px;
}
@media (max-width: 800px) {
  .ai-qv-grid {
    grid-template-columns: 1fr;
  }
}

.ai-qv-gallery-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-qv-main-img-wrap {
  width: 100%;
  height: 280px;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
}
.ai-qv-main-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.ai-qv-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.ai-qv-thumb {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  border: 2px solid #e2e8f0;
  object-fit: contain;
  padding: 4px;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s;
}
.ai-qv-thumb:hover,
.ai-qv-thumb.active {
  border-color: #2563eb;
}

.ai-qv-info-col {
  display: flex;
  flex-direction: column;
}
.ai-qv-pn-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
  margin-bottom: 12px;
}
.ai-qv-pn {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
  color: #0f172a;
}
.ai-qv-copy-btn {
  background: none;
  border: none;
  color: #2563eb;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
}
.ai-qv-stocks {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.ai-qv-stock-badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ai-qv-stock-badge.in {
  background: #dcfce7;
  color: #15803d;
}
.ai-qv-stock-badge.out {
  background: #f1f5f9;
  color: #64748b;
}

.ai-qv-price-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 18px;
}
.ai-qv-price-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 4px;
}
.ai-qv-price-val {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
  margin-bottom: 4px;
}
.ai-qv-vat-sub {
  font-size: 12px;
  color: #64748b;
}

.ai-qv-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
.ai-qv-btn-cart {
  background: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}
.ai-qv-btn-cart:hover {
  background: #1d4ed8;
}
.ai-qv-btn-order {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}
.ai-qv-btn-order:hover {
  background: linear-gradient(135deg, #047857, #059669);
}

.ai-qv-specs-box {
  margin-top: 10px;
}
.ai-qv-specs-box h4 {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 8px;
}
.ai-qv-specs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.ai-qv-specs-table th {
  text-align: left;
  color: #64748b;
  font-weight: 500;
  padding: 6px 0;
  width: 40%;
  border-bottom: 1px solid #f1f5f9;
}
.ai-qv-specs-table td {
  font-weight: 600;
  color: #1e293b;
  padding: 6px 0;
  border-bottom: 1px solid #f1f5f9;
}
.ai-qv-full-link {
  color: #2563eb;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ai-qv-full-link:hover {
  text-decoration: underline;
}
