/* ==========================================================================
   Catálogo Interativo Italac 2026 - Visual Design System
   ========================================================================== */

:root {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --border-color: #334155;
  --border-focus: #3b82f6;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --brand-primary: #2563eb;
  --brand-secondary: #ef4444;
  --brand-accent: #f59e0b;
  
  --accent-gold: #f59e0b;
  --accent-green: #22c55e;
  --accent-blue: #3b82f6;
  
  --whatsapp-green: #25d366;
  --whatsapp-hover: #1da851;
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 20px rgba(37, 211, 102, 0.25);
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --border-color: #e2e8f0;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 120px;
}

/* Header & Navbar */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 16px 24px;
}

[data-theme="light"] .header {
  background-color: rgba(255, 255, 255, 0.88);
}

.header-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1d4ed8, #ef4444);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: var(--shadow-sm);
}

.brand-info h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #f8fafc, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .brand-info h1 {
  background: linear-gradient(135deg, #0f172a, #1d4ed8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-info p {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

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

.view-mode-selector {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 2px;
}

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.view-btn:hover {
  color: var(--text-primary);
}

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

.theme-toggle-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
}

.theme-toggle-btn:hover {
  background: var(--bg-card-hover);
  transform: scale(1.05);
}

/* Controls Section (Search & Filters) */
.controls-section {
  max-width: 1400px;
  margin: 20px auto 0;
  padding: 0 24px;
}

.search-bar-container {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  flex: 1;
  min-width: 280px;
  position: relative;
}

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

.search-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px 12px 46px;
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.select-filter {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.select-filter:focus {
  border-color: var(--border-focus);
}

/* Catalog Container */
.catalog-container {
  max-width: 1400px;
  margin: 20px auto;
  padding: 0 24px;
}

.catalog-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.family-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  margin-bottom: 28px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.family-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(51, 65, 85, 0.6));
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

[data-theme="light"] .family-header {
  background: linear-gradient(135deg, #f8fafc, #e2e8f0);
}

.family-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.family-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.family-badge-count {
  background: rgba(59, 130, 246, 0.2);
  color: var(--accent-blue);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.family-banner-wrapper {
  background: #ffffff;
  padding: 12px;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
  max-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.family-banner-img {
  max-height: 196px;
  max-width: 100%;
  object-fit: contain;
}

/* Family Items List */
.family-items-list {
  display: flex;
  flex-direction: column;
}

.family-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition);
  gap: 16px;
  flex-wrap: wrap;
}

.family-item-row:last-child {
  border-bottom: none;
}

.family-item-row:hover {
  background-color: var(--bg-card-hover);
}

.family-item-row.has-quantity {
  background-color: rgba(37, 211, 102, 0.08);
  border-left: 4px solid var(--whatsapp-green);
}

.item-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 280px;
}

.sku-tag {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border-color);
  color: #f8fafc;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-weight: 700;
  font-size: 0.82rem;
  white-space: nowrap;
}

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

.item-name {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-primary);
}

.item-subtext {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.item-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.meta-pill {
  background: rgba(59, 130, 246, 0.12);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.73rem;
  font-weight: 500;
}

.item-pricing {
  display: flex;
  align-items: center;
  gap: 16px;
}

.price-box {
  display: flex;
  flex-direction: column;
}

.price-edit-input {
  width: 92px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--accent-green);
  font-weight: 700;
  font-size: 0.92rem;
  padding: 5px 8px;
  text-align: right;
  outline: none;
}

.price-edit-input:focus {
  border-color: var(--accent-green);
}

/* Quantity Controls */
.item-qty-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.quantity-control {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
}

.qty-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.qty-btn:hover {
  background: var(--brand-primary);
  color: #ffffff;
}

.qty-input {
  width: 50px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  outline: none;
  -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.preset-buttons {
  display: flex;
  gap: 4px;
}

.preset-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: 4px;
  font-size: 0.72rem;
  padding: 4px 8px;
  cursor: pointer;
  transition: var(--transition);
}

.preset-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--brand-primary);
}

/* Product Cards View */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 20px;
}

.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

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

.product-card.has-quantity {
  border-color: var(--whatsapp-green);
  box-shadow: 0 0 12px rgba(37, 211, 102, 0.15);
}

.card-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.supplier-badge {
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #ffffff;
  background: var(--brand-primary);
}

/* Table View */
.table-view-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.erp-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.erp-table th {
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.78rem;
  text-transform: uppercase;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.erp-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.erp-table tr:hover {
  background-color: var(--bg-card-hover);
}

.erp-table tr.has-quantity {
  background-color: rgba(37, 211, 102, 0.08);
}

/* Sticky Bottom Order Bar */
.sticky-order-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  padding: 16px 24px;
  z-index: 200;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="light"] .sticky-order-bar {
  background: rgba(255, 255, 255, 0.95);
}

.order-bar-container {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.order-metrics {
  display: flex;
  align-items: center;
  gap: 24px;
}

.metric-item {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-val {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-primary);
}

.metric-val.total-price {
  color: var(--accent-green);
  font-size: 1.5rem;
}

.order-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

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

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-whatsapp {
  background: var(--whatsapp-green);
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.btn-whatsapp:hover {
  background: var(--whatsapp-hover);
  transform: translateY(-2px);
}

.btn-danger-soft {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger-soft:hover {
  background: #ef4444;
  color: #ffffff;
}

/* Modal Styling */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 20px;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.25s ease;
}

.modal-backdrop.active .modal-card {
  transform: scale(1);
}

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

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.close-modal-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition);
}

.close-modal-btn:hover {
  color: var(--text-primary);
}

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

.whatsapp-preview-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: monospace;
  font-size: 0.88rem;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 20px;
}

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

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-surface);
  border: 1px solid var(--whatsapp-green);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 500;
}

@media (max-width: 768px) {
  .header-container,
  .order-bar-container {
    flex-direction: column;
    align-items: stretch;
  }
  .order-metrics {
    justify-content: space-between;
  }
  .order-actions {
    justify-content: stretch;
  }
  .order-actions .btn {
    flex: 1;
    justify-content: center;
    padding: 10px 14px;
    font-size: 0.85rem;
  }
  body {
    padding-bottom: 180px;
  }
}
