/* ==========================================================================
   AVENIX COMMERCE — Composants applicatifs partagés
   ========================================================================== */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 18px 20px 0;
}
.panel-head h2, .panel-head h3 { font-size: 14px; font-weight: 800; }
.panel-head p { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.panel-body { padding: 20px; }
.panel-body.tight { padding: 12px 20px 18px; }
.panel-body.flush { padding: 0; }
.panel-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-xs); position: relative; min-width: 0;
}
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--pale); color: var(--blue); display: grid; place-items: center; }
.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.green { background: var(--green-pale); color: var(--green); }
.stat-icon.orange { background: var(--orange-pale); color: #B45309; }
.stat-icon.red { background: var(--red-pale); color: var(--red); }
.stat-icon.violet { background: #F5F3FF; color: var(--violet); }
.stat-icon.navy { background: #EEF2F7; color: var(--navy); }
.stat-value { font-family: var(--font-display); font-size: 25px; font-weight: 800; letter-spacing: -.045em; margin-top: 14px; line-height: 1; }
.stat-label { font-size: 10.5px; color: var(--muted); margin-top: 5px; }
.stat-foot { display: flex; align-items: center; gap: 7px; margin-top: 12px; font-size: 9.5px; color: var(--muted); }
.trend {
  display: inline-flex; align-items: center; gap: 3px; border-radius: 20px;
  padding: 3px 7px; font-size: 9.5px; font-weight: 800; color: var(--green); background: var(--green-pale);
}
.trend svg { width: 11px; height: 11px; }
.trend.down { color: var(--red); background: var(--red-pale); }
.trend.neutral { color: var(--muted); background: #F1F5F9; }

.chart-box { position: relative; width: 100%; height: 280px; }
.chart-box.sm { height: 210px; }
.chart-box.xs { height: 170px; }
.chart-box canvas { max-width: 100%; }

.table-wrap { overflow-x: auto; width: 100%; }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table th {
  text-align: left; padding: 10px 12px; font-size: 9px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); font-weight: 800;
  border-bottom: 1px solid var(--line); background: #FBFCFE;
}
.data-table th:first-child { padding-left: 20px; }
.data-table th:last-child { padding-right: 20px; }
.data-table td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 11.5px; color: var(--text-soft); vertical-align: middle; }
.data-table td:first-child { padding-left: 20px; }
.data-table td:last-child { padding-right: 20px; }
.data-table tbody tr { transition: background .15s ease; }
.data-table tbody tr:hover { background: #FAFCFE; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .primary-cell { font-weight: 800; color: var(--text); }
.data-table .sub-cell { display: block; font-size: 9.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }
.data-table .actions-cell { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-empty { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 12px; }
.table-empty svg { width: 30px; height: 30px; color: var(--muted-light); margin-bottom: 10px; }

.product-cell { display: flex; align-items: center; gap: 10px; min-width: 190px; }
.product-cell img { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: var(--bg); border: 1px solid var(--line); }
.product-cell b { display: block; font-size: 11.5px; font-weight: 800; color: var(--text); max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.product-cell small { display: block; font-size: 9px; color: var(--muted); margin-top: 2px; }
.customer-cell { display: flex; align-items: center; gap: 9px; }
.customer-cell b { display: block; font-size: 11.5px; font-weight: 800; color: var(--text); }
.customer-cell small { display: block; font-size: 9.5px; color: var(--muted); margin-top: 1px; }

.mini-btn {
  width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--line);
  background: #fff; display: inline-grid; place-items: center; color: var(--muted);
  transition: .18s ease;
}
.mini-btn svg { width: 13px; height: 13px; }
.mini-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--pale); }
.mini-btn.danger:hover { border-color: #FECACA; color: var(--red); background: var(--red-pale); }
.mini-btn.green:hover { border-color: #BBF7D0; color: var(--green); background: var(--green-pale); }

.toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-spacer { flex: 1; }
.toolbar .search-box { min-width: 220px; }
.toolbar .input, .toolbar .select { height: 38px; min-height: 38px; font-size: 11.5px; width: auto; }
.toolbar .select { padding-right: 32px; }
.toolbar .btn { min-height: 38px; font-size: 11.5px; }
.segmented { display: inline-flex; background: #F1F5F9; border-radius: 9px; padding: 3px; gap: 2px; }
.segmented button { padding: 6px 11px; border-radius: 7px; font-size: 10.5px; font-weight: 700; color: var(--muted); }
.segmented button.active { background: #fff; color: var(--text); box-shadow: var(--shadow-xs); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 11.5px; color: var(--text-soft); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 38px; height: 22px; border-radius: 20px; background: #CBD5E1; position: relative; transition: .2s ease; flex-shrink: 0; }
.switch-track::after { content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: .2s ease; box-shadow: 0 1px 3px rgba(15,23,42,.2); }
.switch input:checked + .switch-track { background: var(--blue); }
.switch input:checked + .switch-track::after { left: 19px; }

.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.info-list { display: grid; gap: 10px; }
.info-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; font-size: 11.5px; padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.info-row:last-child { border-bottom: 0; padding-bottom: 0; }
.info-row span:first-child { color: var(--muted); }
.info-row span:last-child { font-weight: 700; text-align: right; }

.activity-feed { display: grid; }
.activity-row { display: flex; gap: 11px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.activity-row:last-child { border-bottom: 0; padding-bottom: 0; }
.activity-icon { width: 32px; height: 32px; border-radius: 9px; background: var(--pale); color: var(--blue); display: grid; place-items: center; flex-shrink: 0; }
.activity-icon svg { width: 14px; height: 14px; }
.activity-icon.green { background: var(--green-pale); color: var(--green); }
.activity-icon.orange { background: var(--orange-pale); color: #B45309; }
.activity-icon.red { background: var(--red-pale); color: var(--red); }
.activity-copy { min-width: 0; }
.activity-copy b { display: block; font-size: 11px; font-weight: 700; line-height: 1.4; }
.activity-copy span { display: block; font-size: 9.5px; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.activity-copy time { display: block; font-size: 8.5px; color: var(--muted-light); margin-top: 4px; }

.alert-item { display: flex; align-items: flex-start; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.alert-item:last-child { border-bottom: 0; padding-bottom: 0; }
.alert-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.alert-icon svg { width: 14px; }
.alert-icon.danger { background: var(--red-pale); color: var(--red); }
.alert-icon.warning { background: var(--orange-pale); color: #B45309; }
.alert-icon.info { background: var(--pale); color: var(--blue); }
.alert-copy { flex: 1; min-width: 0; }
.alert-copy b { display: block; font-size: 10.5px; font-weight: 700; }
.alert-copy span { display: block; font-size: 9.5px; color: var(--muted); margin-top: 2px; line-height: 1.45; }
.alert-copy time { display: block; font-size: 8.5px; color: var(--muted-light); margin-top: 4px; }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.quick-action {
  display: flex; align-items: center; gap: 9px; padding: 12px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; text-align: left; transition: .18s ease;
}
.quick-action:hover { border-color: #BFD4F5; background: #FBFDFF; transform: translateY(-1px); }
.quick-action .qa-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--pale); color: var(--blue); display: grid; place-items: center; flex-shrink: 0; }
.quick-action .qa-icon svg { width: 14px; }
.quick-action b { font-size: 10px; font-weight: 700; line-height: 1.35; }
.quick-action small { display: block; font-size: 8.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }

.note-box { background: var(--orange-pale); border: 1px solid #FDE7CB; border-radius: 10px; padding: 13px 15px; font-size: 11px; color: #92400E; line-height: 1.6; display: flex; gap: 9px; }
.note-box svg { width: 15px; flex-shrink: 0; margin-top: 1px; }
.note-box.blue { background: var(--pale); border-color: #D5E5FB; color: var(--blue-ink); }
.note-box.green { background: var(--green-pale); border-color: #BBF7D0; color: #15803D; }
.note-box.red { background: var(--red-pale); border-color: #FECACA; color: #991B1B; }

.invoice-document { background: #fff; color: #1E293B; padding: 36px; border-radius: 12px; }
.invoice-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 30px; padding-bottom: 24px; border-bottom: 2px solid var(--navy); }
.invoice-brand { display: flex; align-items: center; gap: 11px; }
.invoice-brand .logo-mark { width: 44px; height: 44px; }
.invoice-brand b { display: block; font-family: var(--font-display); font-size: 18px; font-weight: 800; }
.invoice-brand small { display: block; font-size: 9px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.invoice-title { text-align: right; }
.invoice-title h2 { font-family: var(--font-display); font-size: 26px; font-weight: 800; letter-spacing: -.04em; }
.invoice-title p { font-size: 10px; color: var(--muted); margin-top: 3px; }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; padding: 24px 0; }
.invoice-party h4 { font-size: 9px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin-bottom: 7px; }
.invoice-party b { display: block; font-size: 12px; }
.invoice-party p { font-size: 10.5px; color: var(--text-soft); line-height: 1.6; margin-top: 2px; }
.invoice-table { width: 100%; border-collapse: collapse; margin: 10px 0 20px; }
.invoice-table th { text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 9px 10px; border-block: 1px solid var(--line); background: #F8FAFC; }
.invoice-table td { padding: 10px; border-bottom: 1px solid var(--line); font-size: 10.5px; }
.invoice-table .num { text-align: right; }
.invoice-totals { margin-left: auto; width: min(310px, 100%); }
.invoice-totals .summary-line { padding: 6px 0; font-size: 10.5px; }
.invoice-totals .summary-line.total { font-size: 13px; margin-top: 6px; padding-top: 11px; }
.invoice-foot { margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; font-size: 9px; color: var(--muted); }
.invoice-stamp { display: inline-flex; align-items: center; gap: 5px; border: 1px solid #BBF7D0; background: var(--green-pale); color: #15803D; border-radius: 6px; padding: 4px 8px; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }

.review-admin-card { border: 1px solid var(--line); border-radius: 11px; padding: 16px; background: #fff; }
.review-admin-card + .review-admin-card { margin-top: 10px; }
.review-admin-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.review-admin-head b { display: block; font-size: 11.5px; }
.review-admin-head small { display: block; font-size: 9.5px; color: var(--muted); margin-top: 2px; }
.review-admin-head .badge { margin-left: auto; }
.review-admin-card h4 { font-size: 11.5px; margin: 7px 0 4px; }
.review-admin-card p { font-size: 11px; color: var(--text-soft); line-height: 1.65; }
.review-admin-foot { display: flex; align-items: center; gap: 7px; margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; flex-wrap: wrap; }
.review-admin-foot .btn { min-height: 30px; padding: 0 9px; font-size: 9.5px; border-radius: 6px; }

.rating-input { display: flex; gap: 3px; }
.rating-input button { color: var(--line-strong); display: grid; place-items: center; }
.rating-input button svg { width: 24px; height: 24px; }
.rating-input button.active { color: var(--orange); }
.rating-input button.active svg { fill: var(--orange); stroke: var(--orange); }

.upload-zone {
  border: 1.5px dashed var(--line-strong); border-radius: 10px; padding: 24px;
  text-align: center; color: var(--muted); font-size: 11px; background: #FBFCFE;
  cursor: pointer; transition: .18s;
}
.upload-zone:hover { border-color: var(--blue); background: var(--pale); color: var(--blue); }
.upload-zone svg { width: 24px; height: 24px; margin-bottom: 7px; }

.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); display: inline-block; }

.chat-shell { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 16px; }
.chat-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; height: 660px; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 11px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.chat-head .assistant-avatar { width: 40px; height: 40px; border-radius: 11px; background: var(--navy); color: #fff; display: grid; place-items: center; }
.chat-head .assistant-avatar svg { width: 19px; }
.chat-head b { display: block; font-size: 12.5px; }
.chat-head small { display: block; font-size: 9.5px; color: var(--green); display: flex; align-items: center; gap: 4px; }
.chat-head small::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; background: #FBFCFE; }
.chat-msg { max-width: 82%; display: flex; gap: 9px; align-items: flex-start; }
.chat-msg .cm-avatar { width: 27px; height: 27px; border-radius: 8px; background: var(--navy); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.chat-msg .cm-avatar svg { width: 13px; }
.chat-msg .bubble { padding: 12px 14px; border-radius: 12px; font-size: 11.5px; line-height: 1.7; }
.chat-msg.ai .bubble { background: #fff; border: 1px solid var(--line); border-top-left-radius: 3px; color: var(--text-soft); }
.chat-msg.user { margin-left: auto; flex-direction: row-reverse; }
.chat-msg.user .bubble { background: var(--blue); color: #fff; border-top-right-radius: 3px; }
.chat-msg.user .cm-avatar { background: #DBEAFE; color: var(--blue); }
.bubble b { color: var(--text); font-weight: 800; }
.chat-msg.user .bubble b { color: #fff; }
.bubble ul { margin: 6px 0; display: grid; gap: 3px; }
.bubble li { padding-left: 13px; position: relative; }
.bubble li::before { content: ''; position: absolute; left: 0; top: 8px; width: 4px; height: 4px; border-radius: 50%; background: var(--blue); }
.chat-source { display: block; margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line); font-size: 8.5px; color: var(--muted-light); }
.chat-typing { display: inline-flex; gap: 3px; padding: 12px 14px; }
.chat-typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--muted-light); animation: typing 1s infinite; }
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.chat-input-row { display: flex; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--line); background: #fff; }
.chat-input-row input { flex: 1; height: 42px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 13px; outline: 0; font-size: 12px; }
.chat-input-row input:focus { border-color: var(--blue); }
.chat-input-row .btn { width: 42px; min-height: 42px; padding: 0; }
.chat-side { display: flex; flex-direction: column; gap: 14px; }
.prompt-list { display: grid; gap: 6px; }
.prompt-btn {
  display: flex; align-items: flex-start; gap: 8px; padding: 9px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; text-align: left; font-size: 10.5px; color: var(--text-soft); line-height: 1.45;
  transition: .18s;
}
.prompt-btn:hover { border-color: #BFD4F5; background: var(--pale); color: var(--blue-ink); }
.prompt-btn svg { width: 13px; color: var(--blue); flex-shrink: 0; margin-top: 1px; }
.insight-stat { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 10.5px; }
.insight-stat:last-child { border-bottom: 0; }
.insight-stat span { color: var(--muted); }
.insight-stat b { font-weight: 800; }

.timeline-admin { padding-left: 2px; }
.step-flow { display: flex; align-items: center; gap: 0; overflow-x: auto; padding: 4px 0 8px; }
.step-flow-item { display: flex; align-items: center; gap: 7px; flex-shrink: 0; }
.step-flow-num { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 9px; font-weight: 800; background: #F1F5F9; color: var(--muted); border: 1px solid var(--line); }
.step-flow-item.done .step-flow-num { background: var(--green); color: #fff; border-color: var(--green); }
.step-flow-item.current .step-flow-num { background: var(--blue); color: #fff; border-color: var(--blue); }
.step-flow-item span { font-size: 9.5px; color: var(--muted); white-space: nowrap; }
.step-flow-item.done span, .step-flow-item.current span { color: var(--text); font-weight: 700; }
.step-flow-line { width: 24px; height: 1px; background: var(--line); margin: 0 6px; flex-shrink: 0; }

.campaign-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.campaign-card + .campaign-card { margin-top: 10px; }
.campaign-head { display: flex; align-items: flex-start; gap: 10px; }
.campaign-icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--pale); color: var(--blue); flex-shrink: 0; }
.campaign-icon svg { width: 16px; }
.campaign-head b { font-size: 12px; }
.campaign-head small { display: block; font-size: 9.5px; color: var(--muted); margin-top: 2px; }
.campaign-head .badge { margin-left: auto; }
.campaign-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line); }
.campaign-stats span { display: block; font-size: 8.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.campaign-stats b { display: block; font-size: 12px; font-weight: 800; margin-top: 2px; }

.kpi-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi-mini { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; }
.kpi-mini span { font-size: 9.5px; color: var(--muted); }
.kpi-mini b { display: block; font-family: var(--font-display); font-size: 18px; font-weight: 800; margin-top: 3px; letter-spacing: -.03em; }

.empty-compact { padding: 26px; text-align: center; color: var(--muted); font-size: 11px; }
.empty-compact svg { width: 22px; height: 22px; margin-bottom: 6px; color: var(--muted-light); }

.separator { height: 1px; background: var(--line); margin: 16px 0; }
.order-total-box { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.order-total-box .summary-line { padding: 4px 0; font-size: 11px; }
.order-total-box .summary-line.total { margin-top: 6px; padding-top: 10px; }
.order-total-box .summary-line.total span:last-child { font-family: var(--font-display); font-size: 17px; font-weight: 800; }

.detail-hero { display: flex; align-items: center; gap: 16px; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; flex-wrap: wrap; }
.detail-hero .avatar-xl { border-radius: 18px; }
.detail-hero-copy { flex: 1; min-width: 180px; }
.detail-hero-copy h1 { font-size: 21px; font-weight: 800; }
.detail-hero-copy p { font-size: 11px; color: var(--muted); margin-top: 3px; }
.detail-hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tag-list { display: flex; gap: 5px; flex-wrap: wrap; }
.tag-list .badge { font-size: 9px; }

.data-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 10.5px; }
.data-bar span { color: var(--muted); }
.data-bar b { font-weight: 800; }

.admin-search-results { max-height: 330px; overflow-y: auto; }
.search-category { padding: 7px 10px 4px; font-size: 8.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted-light); font-weight: 800; }
.search-result {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px;
  border-radius: 7px; text-align: left; font-size: 11.5px; color: var(--text-soft);
}
.search-result:hover { background: var(--bg); color: var(--text); }
.search-result svg { width: 14px; color: var(--muted); }
.search-result img { width: 26px; height: 26px; border-radius: 5px; object-fit: cover; }
.search-result small { margin-left: auto; font-size: 9px; color: var(--muted); }
