/* ═══════════════════════════════════════════════
   IJS GROUP — B2B Portal Styles
   Cart, Login, Orders, Price badges
═══════════════════════════════════════════════ */

/* ── B2B Login Modal ─────────────────────────── */
.b2b-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(3px);
}

.b2b-modal-overlay.open {
  display: flex;
}

.b2b-modal {
  background: var(--surface);
  border-radius: 12px;
  width: 380px;
  max-width: 92vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  overflow: hidden;
}

.b2b-modal-header {
  background: linear-gradient(135deg, #002855 0%, #0057A8 100%);
  padding: 24px 28px;
  color: #fff;
}

.b2b-modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.b2b-modal-header p {
  margin: 6px 0 0;
  font-size: 13px;
  opacity: 0.7;
}

.b2b-modal-body {
  padding: 24px 28px;
}

.b2b-input-group {
  margin-bottom: 16px;
}

.b2b-input-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.b2b-input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.b2b-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0, 87, 168, 0.12);
}

.b2b-btn-primary {
  width: 100%;
  height: 44px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.b2b-btn-primary:hover {
  background: var(--brand2);
}

.b2b-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.b2b-login-error {
  display: none;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

.b2b-modal-footer {
  padding: 0 28px 20px;
  text-align: center;
}

.b2b-modal-footer button:not(.b2b-btn-primary) {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 13px;
  cursor: pointer;
}

.b2b-modal-footer button:not(.b2b-btn-primary):hover {
  color: var(--text);
}

/* ── B2B Error Modal ────────────────────────── */
.b2b-modal-error {
  border-top: 4px solid #dc2626;
}

.b2b-modal-error .b2b-modal-header {
  padding: 20px 28px;
}

.b2b-modal-error .b2b-modal-body p {
  font-weight: 500;
  color: var(--text2);
}

.b2b-modal-error .b2b-modal-footer {
  padding-bottom: 24px;
}

/* ── B2B User Bar ────────────────────────────── */
.b2b-user-bar {
  display: none;
  align-items: center;
  gap: 10px;
  margin-right: 12px;
}

.b2b-user-bar.active {
  display: flex;
}

.b2b-user-info {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  text-align: right;
  line-height: 1.3;
}

.b2b-user-empresa {
  font-weight: 600;
  color: #fff;
  font-size: 12px;
}

.b2b-user-code {
  color: rgba(255, 255, 255, 0.5);
}

.b2b-logout-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.7);
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.b2b-logout-btn:hover {
  background: rgba(232, 64, 14, 0.8);
  border-color: rgba(232, 64, 14, 0.8);
  color: #fff;
}

.b2b-login-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.85);
  border-radius: 4px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.b2b-login-btn:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.b2b-login-btn i {
  font-size: 11px;
}

/* ── Cart Button (topbar) ────────────────────── */
.b2b-cart-btn {
  position: relative;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
  display: none;
}

.b2b-cart-btn.active {
  display: inline-flex;
}

.b2b-cart-btn:hover {
  color: #FFD700;
}

.b2b-cart-badge {
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.b2b-cart-badge.has-items {
  display: flex;
}

/* ── Cart Drawer ─────────────────────────────── */
.b2b-cart-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  max-width: 95vw;
  height: 100vh;
  background: var(--surface);
  box-shadow: -4px 0 30px rgba(0, 0, 0, 0.25);
  z-index: 10001;
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
}

.b2b-cart-drawer.open {
  right: 0;
}

.b2b-cart-drawer-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 10000;
}

.b2b-cart-drawer-backdrop.open {
  display: block;
}

.cart-header {
  background: var(--navy);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.cart-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.cart-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 20px;
  cursor: pointer;
}

.cart-close:hover {
  color: #fff;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}

.cart-item-info {
  flex: 1;
  min-width: 0;
}

.cart-item-ref {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.cart-item-desc {
  font-size: 11px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cart-qty-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-qty-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.cart-qty-val {
  width: 36px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.cart-item-remove {
  background: none;
  border: none;
  color: var(--text3);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
}

.cart-item-remove:hover {
  color: var(--accent);
}

.cart-item-price-info {
  font-size: 11px;
  color: var(--brand);
  font-weight: 500;
  margin-top: 2px;
}

.cart-item-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.cart-item-subtotal {
  font-size: 13px;
  color: var(--text);
}

.cart-summary-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 6px;
  font-weight: 500;
}

.cart-summary-sep {
  opacity: 0.5;
}

.cart-summary-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  color: var(--text);
}

.cart-summary-total>span:first-child {
  font-size: 14px;
  font-weight: 700;
  color: var(--text2);
}

.cart-grand-total {
  font-size: 20px;
  font-weight: 800;
  color: var(--brand);
}

.text-muted {
  color: var(--text4);
}

.cart-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text3);
}

.cart-empty i {
  font-size: 40px;
  display: block;
  margin-bottom: 12px;
  opacity: 0.3;
}

.cart-footer {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
  flex-shrink: 0;
}

.cart-summary {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.cart-confirm-btn {
  width: 100%;
  height: 46px;
  background: var(--green);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.cart-confirm-btn:hover {
  background: #15803d;
}

.cart-confirm-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.cart-clear-btn {
  width: 100%;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  margin-top: 8px;
}

.cart-clear-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Order Confirmation Modal ────────────────── */
.b2b-order-modal .b2b-modal {
  width: 480px;
}

.order-select-group {
  margin-bottom: 16px;
}

.order-select-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.order-select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  cursor: pointer;
}

.order-textarea {
  width: 100%;
  height: 70px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
  font-family: var(--font);
  box-sizing: border-box;
}

.order-success {
  display: none;
  text-align: center;
  padding: 30px 20px;
}

/* ══════════════════════════════════════════════════════
   ORDERS VIEW - EXPANDABLE
   ══════════════════════════════════════════════════════ */
.orders-view-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 30px;
  box-shadow: var(--shadow);
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.orders-view-header {
  background: var(--surface2);
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.orders-view-header h2 {
  font-size: 18px;
  color: var(--brand);
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.orders-view-header p {
  color: var(--text3);
  font-size: 12px;
}

.orders-table-wrapper {
  overflow-x: auto;
}

.order-row-main {
  cursor: pointer;
  transition: background 0.2s;
}

.order-row-main:hover {
  background: var(--brand-bg);
}

.order-row-main td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text2);
}

.order-expand-icon {
  font-size: 10px;
  color: var(--text4);
  text-align: center;
  transition: transform 0.3s;
}

.order-expand-icon.expanded {
  transform: rotate(90deg);
  color: var(--brand);
}

/* Status Badges */
.os-badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.os-pendiente {
  background: #fef3c7;
  color: #92400e;
}

.os-preparacion {
  background: #f3e8ff;
  color: #6b21a8;
}

.os-enviado {
  background: #dcfce7;
  color: #166534;
}

.os-procesado {
  background: #e0f2fe;
  color: #075985;
}

.os-error {
  background: #fee2e2;
  color: #991b1b;
}

/* Expanded Details */
.order-row-details {
  background: #fdfdfe;
}

.order-details-content {
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.order-items-table {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  border-collapse: collapse;
  font-size: 12px;
}

.order-items-table th {
  background: #f8fafc;
  color: var(--text2);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.order-items-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
}

.order-items-table tr:last-child td {
  border-bottom: 0;
}

.order-success.show {
  display: block;
}

.order-success i {
  font-size: 48px;
  color: var(--green);
  display: block;
  margin-bottom: 14px;
}

.order-success h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.order-success p {
  color: var(--text2);
  font-size: 13px;
}

/* ── Add to Cart Button (article rows) ───────── */
.b2b-add-cart-container {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
}

.b2b-price-badge {
  display: none;
  align-items: center;
  margin: 6px 0;
}

.b2b-price-row {
  grid-column: 1 / -1;
  display: none;
  align-items: center;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-top: 2px;
}

.b2b-price-container {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#d-price-row .b2b-price-container {
  gap: 20px;
}

.b2b-price-block {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
}

#d-price-row .b2b-price-block {
  align-items: flex-start;
}

.b2b-price-label {
  font-size: 9px;
  font-weight: 800;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1;
}

#d-price-row .b2b-price-label {
  font-size: 11px;
  line-height: 1.2;
}

.b2b-add-cart {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  margin-top: 4px;
}

.b2b-add-cart:hover {
  background: var(--brand2);
  transform: translateY(-1px);
}

.b2b-add-cart.visible {
  display: inline-flex;
}

.b2b-add-cart:active {
  transform: scale(0.97);
}

.b2b-add-cart i {
  font-size: 12px;
}

/* ── My Orders nav ───────────────────────────── */
.b2b-orders-view {
  display: none;
}

.b2b-orders-view.active {
  display: block;
}

.orders-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.orders-table th {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text2);
  text-align: left;
}

.orders-table td {
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--bg);
}

.order-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.order-status.pendiente {
  background: #fef3c7;
  color: #92400e;
}

.order-status.enviado {
  background: #dbeafe;
  color: #1e40af;
}

.order-status.procesado {
  background: #d1fae5;
  color: #065f46;
}

.order-status.error {
  background: #fef2f2;
  color: #dc2626;
}

/* ── Price Badge ─────────────────────────────── */
.b2b-price {
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
}

.b2b-price-base {
  text-decoration: line-through;
  color: var(--text3);
  font-size: 11px;
  margin-right: 4px;
}

#d-price-row .b2b-price-base {
  font-size: 14px;
}

.b2b-price-dto {
  color: #dc2626;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 4px;
  background: rgba(220, 38, 38, 0.1);
  border-radius: 3px;
  width: fit-content;
}

#d-price-row .b2b-price-dto {
  font-size: 14px;
  padding: 2px 6px;
}

.b2b-price-final {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand);
}

#d-price-row .b2b-price-final {
  font-size: 22px;
}

/* ── Stock Chips ─────────────────────────────── */
.b2b-stock-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.b2b-stock-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.b2b-stock-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.b2b-stock-chip {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  line-height: 1;
  border: 1px solid transparent;
  white-space: nowrap;
}

.b2b-stock-chip.status-av {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
  border-color: rgba(34, 197, 94, 0.2);
}

.b2b-stock-chip.status-out {
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.15);
}

/* ── B2B Add to Cart Button ────────────────── */
.b2b-add-cart:disabled {
  background: #f3f4f6 !important;
  color: #9ca3af !important;
  border-color: #e5e7eb !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
}

/* ── B2B Notify Me Button ─────────────────── */
.b2b-notify-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  padding: 12px 20px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.b2b-notify-btn:hover {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.4);
  transform: translateY(-1px);
}

.b2b-notify-btn i {
  font-size: 15px;
}