/* =============================================================
   COMMERCIAL-FEATURES.CSS — GourmetRevient v6.0
   🛒 Smart Order Builder + 📦 Bon d'Économat
   🚨 Waste Report + 🌐 E-Catalogue
   ============================================================= */

/* ============================================================= */
/* 1. SMART ORDER BUILDER — Recipe Picker in CRM                  */
/* ============================================================= */

.smart-order-lines {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.smart-order-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem;
  background: var(--bg-alt);
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--surface-border);
  animation: fadeUp 0.3s ease-out;
}

.smart-order-line:hover {
  border-color: var(--accent);
}

.sol-remove {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--surface-border);
  background: var(--surface, #fff);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.sol-remove:hover {
  background: var(--danger, #ef4444);
  color: white;
  border-color: var(--danger, #ef4444);
}

.sol-unit-cost {
  line-height: 1.2;
}

/* Margin Analysis Panel */
.smart-order-margin {
  margin-top: 1rem;
  padding: 1rem;
  background: linear-gradient(135deg, rgba(197, 165, 90, 0.06) 0%, rgba(16, 185, 129, 0.04) 100%);
  border: 1px solid rgba(197, 165, 90, 0.15);
  border-radius: 12px;
  animation: fadeUp 0.4s ease-out;
}

.margin-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.margin-icon { font-size: 1rem; }

.margin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.75rem;
}

.margin-item {
  text-align: center;
  padding: 0.6rem;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 8px;
}

.dark-theme .margin-item {
  background: rgba(255, 255, 255, 0.05);
}

.margin-item.highlight {
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.15);
}

.margin-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  margin-bottom: 0.3rem;
}

.margin-val {
  display: block;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

.margin-val.accent {
  color: var(--accent);
}

/* Order Cards Margin Badge */
.order-margin-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.7rem;
  font-weight: 800;
  margin: 0.4rem 0;
  letter-spacing: 0.02em;
}

.order-margin-badge.margin-good {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
}

.order-margin-badge.margin-warn {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.order-margin-badge.margin-bad {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* Order Items Detail Chips */
.order-items-detail {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0.4rem 0;
}

.order-item-chip {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-alt);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary, var(--text-muted));
}


/* ============================================================= */
/* 2. BON D'ÉCONOMAT — Explosion des Besoins (PREMIUM)            */
/* ============================================================= */

#bonEconomatResults {
  background: var(--surface, white);
  border-radius: 20px;
  border: 1px solid var(--surface-border);
  padding: 2rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(12px);
}

.bon-economat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.2rem;
  border-bottom: 3px solid var(--accent, #c5a55a);
  position: relative;
}

.bon-economat-header::after {
  content: '';
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent, #c5a55a), transparent);
}

.bon-economat-header h3 {
  font-family: var(--font-heading, var(--font-display, serif));
  font-size: 1.5rem;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.01em;
}

.bon-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.bon-meta span {
  background: var(--bg-alt);
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid var(--surface-border);
}

.bon-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.bon-kpi {
  text-align: center;
  padding: 1.5rem 1rem;
  background: linear-gradient(135deg, var(--surface, white), var(--bg-alt));
  border-radius: 16px;
  border: 1px solid var(--surface-border);
  border-left: 5px solid;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: default;
}

.bon-kpi:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.bon-kpi-val {
  font-size: 2rem;
  font-weight: 900;
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.02em;
  line-height: 1;
}

.bon-kpi-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  margin-top: 0.5rem;
}

/* Bon Table Premium */
.bon-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.bon-table thead th {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 800;
  padding: 1rem;
  background: linear-gradient(135deg, var(--bg-alt), var(--surface, #f8f8f8));
  border-bottom: 2px solid var(--surface-border);
  color: var(--text-muted);
  white-space: nowrap;
}

.bon-table tbody td {
  padding: 0.8rem 1rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--surface-border);
  transition: background 0.15s ease;
}

.bon-table tbody tr:hover td {
  background: rgba(197, 165, 90, 0.03);
}

.bon-row.bon-critical td {
  background: rgba(239, 68, 68, 0.02);
}

.bon-row.bon-critical td:first-child {
  border-left: 4px solid var(--danger, #ef4444);
  font-weight: 700;
}

.bon-row.bon-partial td:first-child {
  border-left: 4px solid var(--warning, #f59e0b);
  font-weight: 600;
}

.bon-row.bon-ok td:first-child {
  border-left: 4px solid var(--success, #10b981);
}

.bon-row.bon-ok {
  opacity: 0.5;
}

.bon-row.bon-ok:hover {
  opacity: 0.8;
}

.text-bold {
  font-weight: 800;
  color: var(--danger, #ef4444);
  font-size: 0.9rem;
}

.bon-recipe-chip {
  display: inline-block;
  padding: 2px 8px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.06));
  color: #6366f1;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  margin: 1px;
  border: 1px solid rgba(99, 102, 241, 0.1);
}

.bon-recipes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.bon-status-badge {
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

.bon-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 2px dashed var(--surface-border);
  justify-content: flex-end;
}

.bon-actions .btn {
  font-weight: 700;
  padding: 0.7rem 1.5rem;
}

/* ============================================================= */
/* 2b. WASTE REPORT QUOTE — Chef's Humor                          */
/* ============================================================= */

.waste-report-quote {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem 1.2rem;
  background: linear-gradient(135deg, rgba(197, 165, 90, 0.06), rgba(197, 165, 90, 0.02));
  border: 1px solid rgba(197, 165, 90, 0.15);
  border-radius: 12px;
  margin-bottom: 1.5rem;
}

.waste-quote-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.waste-report-quote p {
  font-size: 0.88rem;
  color: var(--text-secondary, var(--text-muted));
  margin: 0;
  line-height: 1.4;
}

.waste-report-quote em {
  font-style: italic;
  color: var(--accent, #c5a55a);
  font-weight: 600;
}


/* ============================================================= */
/* 3. WASTE MONTHLY REPORT                                        */
/* ============================================================= */

.waste-report-card {
  background: var(--surface, white);
  border-radius: 16px;
  border: 1px solid var(--surface-border);
  padding: 1.5rem;
  animation: fadeUp 0.4s ease-out;
}

.waste-report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.waste-report-header h4 {
  font-family: var(--font-display, serif);
  font-size: 1.1rem;
  margin: 0;
}

.waste-report-period {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-alt);
  padding: 4px 12px;
  border-radius: 100px;
}

.waste-report-hero {
  text-align: center;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: rgba(239, 68, 68, 0.04);
  border-radius: 12px;
  border: 1px dashed rgba(239, 68, 68, 0.15);
}

.waste-report-amount {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--danger, #ef4444);
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.02em;
}

.waste-report-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-top: 0.3rem;
}

.waste-report-insight {
  display: flex;
  gap: 0.8rem;
  padding: 1rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.06), rgba(139, 92, 246, 0.04));
  border: 1px solid rgba(99, 102, 241, 0.12);
  border-radius: 12px;
  margin-bottom: 1.5rem;
  align-items: flex-start;
}

.waste-insight-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.waste-report-insight p {
  font-size: 0.85rem;
  color: var(--text-secondary, var(--text-muted));
  line-height: 1.5;
  margin: 0;
}

/* Breakdown Bars */
.waste-report-breakdown {
  margin-bottom: 1.5rem;
}

.waste-report-breakdown h5,
.waste-report-trend h5 {
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
}

.waste-bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.waste-bar-label {
  flex: 0 0 120px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
}

.waste-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-alt);
  border-radius: 100px;
  overflow: hidden;
}

.waste-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #f59e0b);
  border-radius: 100px;
  transition: width 0.6s ease-out;
}

.waste-bar-val {
  flex: 0 0 100px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Trend Chart */
.waste-report-trend {
  padding-top: 1rem;
  border-top: 1px dashed var(--surface-border);
}

.waste-trend-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 120px;
  padding: 0.5rem 0;
}

.waste-trend-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  justify-content: flex-end;
}

.waste-trend-bar {
  width: 100%;
  max-width: 40px;
  background: linear-gradient(180deg, #ef4444, #f97316);
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  transition: height 0.6s ease-out;
}

.waste-trend-label {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 0.4rem;
}

.waste-trend-val {
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--text);
  margin-top: 0.1rem;
}


/* ============================================================= */
/* 4. E-CATALOGUE PORTAL                                          */
/* ============================================================= */

#eCatalogueModal .modal-content {
  overflow: hidden;
}

#eCataloguePreviewArea iframe {
  border-radius: 8px;
}

#eCatalogueActions .btn {
  white-space: nowrap;
}

/* ============================================================= */
/* 5. RESPONSIVE                                                  */
/* ============================================================= */

@media (max-width: 768px) {
  .margin-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .bon-kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .smart-order-line {
    flex-wrap: wrap;
  }
  
  .smart-order-line .sol-recipe,
  .smart-order-line .sol-recipe-custom {
    flex: 1 1 100% !important;
  }
  
  .waste-bar-label {
    flex: 0 0 80px;
    font-size: 0.7rem;
  }
  
  .waste-bar-val {
    flex: 0 0 70px;
    font-size: 0.65rem;
  }
  
  .bon-actions {
    flex-direction: column;
  }
}
