/**
 * Mec-Gar B2B — CSS
 * Tutti gli stili con prefisso .mec-b2b-* per evitare conflitti con Rey/Elementor.
 * Enqueued solo sulla pagina B2B.
 */

/* ============================================================
   Reset scoped + variabili
   ============================================================ */

.mec-b2b-wrap *,
.mec-b2b-wrap *::before,
.mec-b2b-wrap *::after {
  box-sizing: border-box;
}

:root {
  --b2b-primary:     #1a1a2e;
  --b2b-accent:      #c8a84b;
  --b2b-success:     #9de747;
  --b2b-warning:     #f59e0b;
  --b2b-danger:      #dc2626;
  --b2b-bg:          #ffffff;
  --b2b-surface:     #ffffff;
  --b2b-border:      #e2e8f0;
  --b2b-text:        #1a202c;
  --b2b-text-muted:  #64748b;
  --b2b-radius:      8px;
  --b2b-shadow:      0 1px 4px rgba(0,0,0,0.06);
  --b2b-shadow-lg:   0 4px 16px rgba(0,0,0,0.10);
}

[x-cloak] { display: none !important; }

/* ============================================================
   Layout base
   ============================================================ */

.mec-b2b-wrap {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--b2b-text);
  background: var(--b2b-bg);
  min-height: 100vh;
}

.mec-b2b-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0;
}

.mec-b2b-main {
  padding: 16px 0 32px;
}

/* ============================================================
   Override tema — sfondo bianco e titolo pagina nascosto
   ============================================================ */

body.mec-b2b-active,
body.mec-b2b-active #page,
body.mec-b2b-active .site-content,
body.mec-b2b-active #content,
body.mec-b2b-active main,
body.mec-b2b-active .site-main,
body.mec-b2b-active article,
body.mec-b2b-active .entry-content,
body.mec-b2b-active .reycore-woocommerce-page-container {
  background: #ffffff !important;
  background-color: #ffffff !important;
}

/* Nascondi il titolo pagina del tema (fallback CSS oltre al filtro PHP) */
body.mec-b2b-active .entry-title,
body.mec-b2b-active .page-title,
body.mec-b2b-active .woocommerce-page-title,
body.mec-b2b-active .page-header,
body.mec-b2b-active .rey-entryTitle {
  display: none !important;
}

/* ============================================================
   Portal header (dashboard + order)
   ============================================================ */

.mec-b2b-portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--b2b-border);
}

.mec-b2b-portal-header-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

/* Il titolo non deve prendere tutta la larghezza (i temi forzano width:100% sugli h1) */
.mec-b2b-portal-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--b2b-primary);
  margin: 0;
  width: auto !important;
  display: block;
}

.mec-b2b-portal-subtitle {
  color: var(--b2b-text-muted);
  font-size: 14px;
  margin: 0 0 20px;
}

.mec-b2b-back-link {
  color: var(--b2b-text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s;
}

.mec-b2b-back-link:hover { color: var(--b2b-primary); }

.mec-b2b-logout-link {
  color: var(--b2b-text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s;
}

.mec-b2b-logout-link:hover { color: var(--b2b-danger); }

/* ============================================================
   Login card
   ============================================================ */

.mec-b2b-login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 24px;
}

.mec-b2b-login-card {
  background: var(--b2b-surface);
  border-radius: 12px;
  box-shadow: var(--b2b-shadow-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
}

.mec-b2b-login-logo {
  text-align: center;
  margin-bottom: 24px;
}

.mec-b2b-login-logo img { max-height: 60px; }

.mec-b2b-site-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--b2b-primary);
}

.mec-b2b-login-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  margin: 0 0 8px;
  color: var(--b2b-primary);
}

.mec-b2b-login-subtitle {
  text-align: center;
  color: var(--b2b-text-muted);
  margin: 0 0 28px;
}

.mec-b2b-login-form { display: flex; flex-direction: column; gap: 16px; }

.mec-b2b-login-help {
  text-align: center;
  color: var(--b2b-text-muted);
  font-size: 13px;
  margin-top: 16px;
}

/* ============================================================
   Form elements
   ============================================================ */

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

.mec-b2b-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--b2b-text);
}

.mec-b2b-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--b2b-border);
  border-radius: var(--b2b-radius);
  font-size: 15px;
  color: var(--b2b-text);
  background: #fff;
  transition: border-color 0.2s;
  outline: none;
}

.mec-b2b-input:focus {
  border-color: var(--b2b-accent);
  box-shadow: 0 0 0 3px rgba(200,168,75,0.15);
}

/* ============================================================
   Buttons
   ============================================================ */

.mec-b2b-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px;
  padding: 11px 22px !important;
  border-radius: var(--b2b-radius) !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  cursor: pointer;
  border: 2px solid transparent !important;
  text-decoration: none !important;
  transition: all 0.2s;
  line-height: 1 !important;
  box-shadow: none !important;
}

.mec-b2b-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.mec-b2b-btn.mec-b2b-btn-primary {
  background: #253b86 !important;
  color: #ffffff !important;
  border-color: #253b86 !important;
}

.mec-b2b-btn.mec-b2b-btn-primary:hover:not(:disabled) {
  background: #1a2d6b !important;
  border-color: #1a2d6b !important;
  color: #ffffff !important;
}

.mec-b2b-btn.mec-b2b-btn-outline {
  background: #ffffff !important;
  color: #253b86 !important;
  border-color: #253b86 !important;
}

.mec-b2b-btn.mec-b2b-btn-outline:hover:not(:disabled) {
  background: #253b86 !important;
  border-color: #253b86 !important;
  color: #ffffff !important;
}

.mec-b2b-btn.mec-b2b-btn-sm {
  padding: 6px 14px !important;
  font-size: 13px !important;
}

.mec-b2b-btn.mec-b2b-btn-full { width: 100%; }

.mec-b2b-btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--b2b-text-muted);
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.15s;
}

.mec-b2b-btn-icon:hover { background: var(--b2b-bg); color: var(--b2b-danger); }
.mec-b2b-btn-remove:hover { color: var(--b2b-danger); }

/* ============================================================
   Alerts
   ============================================================ */

.mec-b2b-alert {
  padding: 14px 16px;
  border-radius: var(--b2b-radius);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.mec-b2b-alert-error {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #991b1b;
}

.mec-b2b-alert-warning {
  background: #fef9c3;
  border-color: #fde047;
  color: #713f12;
}

.mec-b2b-alert ul { margin: 8px 0 0 0; padding-left: 20px; }
.mec-b2b-alert p { margin: 8px 0 0 0; }

/* ============================================================
   Step indicator
   ============================================================ */

.mec-b2b-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.mec-b2b-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.mec-b2b-step-num {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--b2b-border);
  color: var(--b2b-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  transition: all 0.3s;
}

.mec-b2b-step.active .mec-b2b-step-num {
  background: #9de747;
  color: var(--b2b-primary);
}

.mec-b2b-step.done .mec-b2b-step-num {
  background: #253b86;
  color: #fff;
}

.mec-b2b-step-label {
  font-size: 12px;
  color: var(--b2b-text-muted);
  white-space: nowrap;
}

.mec-b2b-step.active .mec-b2b-step-label { color: var(--b2b-text); font-weight: 600; }
.mec-b2b-step.done .mec-b2b-step-label { color: #253b86; }

.mec-b2b-step-line {
  height: 2px;
  width: 60px;
  background: var(--b2b-border);
  margin-bottom: 24px;
  transition: background 0.3s;
}

.mec-b2b-step-line.done { background: #253b86; }

/* ============================================================
   Dashboard
   ============================================================ */

.mec-b2b-page-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--b2b-primary);
  margin: 0 0 8px;
}

.mec-b2b-page-subtitle {
  color: var(--b2b-text-muted);
  margin: 0 0 16px;
}

.mec-b2b-dashboard-hero {
  margin-bottom: 16px;
}

.mec-b2b-badge {
  display: inline-block;
  padding: 4px 12px;
  background: var(--b2b-primary);
  color: #253b86;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}

.mec-b2b-method-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 640px) {
  .mec-b2b-method-cards { grid-template-columns: 1fr; }
}

.mec-b2b-method-card {
  background: var(--b2b-surface);
  border: 2px solid var(--b2b-border);
  border-radius: 12px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  text-decoration: none;
  color: var(--b2b-text);
  transition: all 0.2s;
  cursor: pointer;
}

.mec-b2b-method-card:hover {
  border-color: #253b86;
  box-shadow: var(--b2b-shadow-lg);
  transform: translateY(-2px);
  color: var(--b2b-text);
}

.mec-b2b-method-icon {
  color: #253b86;
  margin-bottom: 16px;
}

.mec-b2b-method-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--b2b-primary);
}

.mec-b2b-method-desc {
  font-size: 14px;
  color: var(--b2b-text-muted);
  margin: 0 0 16px;
  line-height: 1.5;
}

.mec-b2b-method-cta {
  font-weight: 600;
  color: #253b86;
}

.mec-b2b-info-box {
  background: var(--b2b-surface);
  border: 1px solid var(--b2b-border);
  border-radius: var(--b2b-radius);
  padding: 20px 24px;
  margin-top: 16px;
}

.mec-b2b-info-box h3 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--b2b-primary);
}

.mec-b2b-info-box ul {
  margin: 0;
  padding-left: 20px;
  color: var(--b2b-text-muted);
  font-size: 14px;
}

.mec-b2b-info-box li { margin-bottom: 4px; }

.mec-b2b-order-rules { font-size: 14px; color: var(--b2b-text-muted); line-height: 1.6; }
.mec-b2b-order-rules p { margin: 0 0 6px; }
.mec-b2b-order-rules ul, .mec-b2b-order-rules ol { margin: 0 0 6px; padding-left: 20px; }

.mec-b2b-rules-contact {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--b2b-text-muted);
}

.mec-b2b-rules-contact a { color: var(--b2b-primary); }

/* ============================================================
   Tabs
   ============================================================ */

.mec-b2b-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--b2b-border);
  margin-bottom: 24px;
}

.mec-b2b-tab {
  padding: 12px 24px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--b2b-text-muted);
  transition: all 0.2s;
}

.mec-b2b-tab:hover { color: var(--b2b-text); }

.mec-b2b-tab.active {
  color: var(--b2b-primary);
  border-bottom-color: var(--b2b-accent);
}

.mec-b2b-tab-content {
  padding-top: 8px;
}

/* ============================================================
   Dropzone
   ============================================================ */

.mec-b2b-dropzone {
  border: 2px dashed var(--b2b-border);
  border-radius: 12px;
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #fafbfc;
  margin-bottom: 24px;
}

.mec-b2b-dropzone:hover,
.mec-b2b-dropzone.dragging {
  border-color: var(--b2b-accent);
  background: rgba(200,168,75,0.05);
}

.mec-b2b-dropzone.has-file {
  border-style: solid;
  border-color: var(--b2b-success);
  background: rgba(33,163,102,0.05);
}

.mec-b2b-dropzone-placeholder p {
  margin: 8px 0;
  color: var(--b2b-text-muted);
}

.mec-b2b-dropzone-placeholder p:first-of-type {
  font-size: 16px;
  color: var(--b2b-text);
}

.mec-b2b-dropzone-hint {
  font-size: 13px !important;
}

.mec-b2b-file-input { display: none; }

.mec-b2b-dropzone-file {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--b2b-success);
}

/* ============================================================
   Search prodotti
   ============================================================ */

.mec-b2b-search-row {
  margin-bottom: 24px;
}

.mec-b2b-search-wrap { position: relative; }

.mec-b2b-search-input {
  font-size: 15px;
  padding: 12px 16px;
}

.mec-b2b-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--b2b-surface);
  border: 1.5px solid var(--b2b-border);
  border-radius: var(--b2b-radius);
  box-shadow: var(--b2b-shadow-lg);
  z-index: 100;
  max-height: 320px;
  overflow-y: auto;
}

.mec-b2b-search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--b2b-border);
  transition: background 0.15s;
}

.mec-b2b-search-result:last-child { border-bottom: none; }
.mec-b2b-search-result:hover { background: var(--b2b-bg); }

.mec-b2b-sku-badge {
  background: var(--b2b-primary);
  color: var(--b2b-accent);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  white-space: nowrap;
  font-family: monospace;
}

.mec-b2b-product-name {
  flex: 1;
  font-size: 14px;
  color: var(--b2b-text);
}

.mec-b2b-product-price {
  font-weight: 700;
  color: var(--b2b-primary);
  white-space: nowrap;
  font-size: 14px;
}

.mec-b2b-min-qty {
  font-size: 11px;
  font-weight: 400;
  color: var(--b2b-text-muted);
  margin-left: 6px;
}

/* ============================================================
   Tabella ordine
   ============================================================ */

.mec-b2b-table-wrap {
  overflow-x: auto;
  margin-bottom: 24px;
  border-radius: var(--b2b-radius);
  border: 1px solid var(--b2b-border);
  box-shadow: var(--b2b-shadow);
}

.mec-b2b-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.mec-b2b-table thead {
  background: var(--b2b-primary);
  color: #fff;
}

.mec-b2b-table th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

.mec-b2b-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--b2b-border);
  vertical-align: middle;
}

.mec-b2b-table tbody tr:last-child td { border-bottom: none; }
.mec-b2b-table tbody tr:hover td { background: #f8f9fa; }

.mec-b2b-table tfoot td {
  padding: 12px 14px;
  background: #f1f5f9;
  border-top: 2px solid var(--b2b-border);
}

.mec-b2b-row-warning td { background: #fef9c3 !important; }

.mec-b2b-right { text-align: right; }
.mec-b2b-center { text-align: center; }
.mec-b2b-bold { font-weight: 700; }

.mec-b2b-total { font-size: 16px; color: var(--b2b-primary); }

.mec-b2b-sku {
  font-family: monospace;
  font-size: 12px;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--b2b-primary);
}

.mec-b2b-qty-input {
  width: 80px;
  padding: 6px 8px;
  border: 1.5px solid var(--b2b-border);
  border-radius: 4px;
  font-size: 14px;
  text-align: center;
}

.mec-b2b-qty-input:focus {
  border-color: var(--b2b-accent);
  outline: none;
}

/* ============================================================
   Sezione title, badges
   ============================================================ */

.mec-b2b-section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--b2b-primary);
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mec-b2b-badge-sm {
  font-size: 12px;
  font-weight: 400;
  background: var(--b2b-bg);
  border: 1px solid var(--b2b-border);
  border-radius: 12px;
  padding: 2px 10px;
  color: var(--b2b-text-muted);
}

/* ============================================================
   Actions bar
   ============================================================ */

.mec-b2b-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 16px;
}

.mec-b2b-actions-center { justify-content: center; }

/* ============================================================
   Loading / Spinner
   ============================================================ */

.mec-b2b-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--b2b-text-muted);
  font-size: 14px;
  padding: 12px 0;
}

.mec-b2b-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--b2b-border);
  border-top-color: #253b86;
  border-radius: 50%;
  animation: mec-spin 0.7s linear infinite;
}

.mec-b2b-spinner-large {
  display: block;
  width: 48px;
  height: 48px;
  border: 4px solid var(--b2b-border);
  border-top-color: #253b86;
  border-radius: 50%;
  animation: mec-spin 0.7s linear infinite;
  margin: 0 auto 16px;
}

@keyframes mec-spin {
  to { transform: rotate(360deg); }
}

.mec-b2b-step-sending {
  text-align: center;
  padding: 80px 0;
  color: var(--b2b-text-muted);
  font-size: 16px;
}

/* ============================================================
   Conferma (Step 4)
   ============================================================ */

.mec-b2b-confirmation {
  text-align: center;
  padding: 48px 0;
  max-width: 560px;
  margin: 0 auto;
}

.mec-b2b-confirmation-icon { margin-bottom: 24px; }

.mec-b2b-confirmation-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--b2b-success);
  margin: 0 0 24px;
}

.mec-b2b-reference-box {
  background: #253b86;
  border-radius: 12px;
  padding: 24px 32px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.mec-b2b-reference-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.6);
}

.mec-b2b-reference-number {
  font-size: 28px;
  font-weight: 700;
  font-family: monospace;
  color: #ffffff;
  letter-spacing: 2px;
}

.mec-b2b-confirmation-message {
  font-size: 16px;
  color: var(--b2b-text-muted);
  margin-bottom: 24px;
  line-height: 1.7;
}

.mec-b2b-confirmation-summary {
  background: var(--b2b-bg);
  border: 1px solid var(--b2b-border);
  border-radius: var(--b2b-radius);
  padding: 16px 24px;
  margin-bottom: 32px;
}

.mec-b2b-confirmation-summary h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--b2b-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mec-b2b-confirmation-summary p {
  margin: 0;
  font-size: 16px;
  color: var(--b2b-text);
}

/* ============================================================
   Empty state
   ============================================================ */

.mec-b2b-empty-state {
  text-align: center;
  color: var(--b2b-text-muted);
  padding: 48px 0;
  font-size: 15px;
}

/* ============================================================
   Preview table wrap
   ============================================================ */

.mec-b2b-preview-table-wrap {
  margin-top: 24px;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  .mec-b2b-login-card { padding: 28px 20px; }
  .mec-b2b-portal-header { flex-wrap: wrap; gap: 8px; }
  .mec-b2b-portal-title { font-size: 18px; }

  .mec-b2b-step-label { display: none; }
  .mec-b2b-step-line { width: 32px; }

  .mec-b2b-tabs { overflow-x: auto; }
  .mec-b2b-tab { padding: 10px 16px; font-size: 14px; }

  .mec-b2b-actions { flex-direction: column; }
  .mec-b2b-btn { width: 100%; justify-content: center; }

  .mec-b2b-reference-number { font-size: 20px; }
}
