/* ═══════════════════════════════════════════════════════════════════
 *  ShippingHub — OPC Front-end CSS
 * ═══════════════════════════════════════════════════════════════════ */

/* ── CSS variables (injected inline per design settings) ─────────── */
:root {
  --sh-c1: #1d4ed8;
  --sh-c2: #f0f6ff;
  --sh-c3: #bfdbfe;
  --sh-c4: #0b1736;
  --sh-r:  8px;
}

/* ── Wrapper ─────────────────────────────────────────────────────── */
.sh-opc-wrapper {
  margin-top: 14px;
  margin-bottom: 24px;
}

/* ── Section cards ───────────────────────────────────────────────── */
.sh-section {
  background: #fff;
  border: 1px solid var(--sh-c3);
  border-radius: var(--sh-r);
  margin-bottom: 12px;
  overflow: hidden;
}

.sh-section-head {
  background: var(--sh-c1);
  color: #fff;
  padding: 9px 14px;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sh-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255,255,255,.22);
  font-size: 12px;
  font-weight: 800;
  flex-shrink: 0;
}

.sh-section-body {
  padding: 12px 14px;
}

/* ── Form layout ─────────────────────────────────────────────────── */
.sh-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
@media (max-width: 576px) {
  .sh-form-row { grid-template-columns: 1fr; }
}

.sh-form-g {
  display: flex;
  flex-direction: column;
}

.sh-form-g label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 5px;
}

.sh-form-g .form-control {
  border-radius: calc(var(--sh-r) * 0.75);
}

/* ── Logged-in info ──────────────────────────────────────────────── */
.sh-logged-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--sh-r);
  padding: 8px 12px;
  font-size: 13px;
  color: #166534;
  margin-bottom: 10px;
}
.sh-logged-main {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sh-logged-info .material-icons {
  color: #16a34a;
  font-size: 20px;
  flex-shrink: 0;
}
.sh-logged-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.3;
}
.sh-logged-text strong {
  font-size: 13px;
  color: #14532d;
}
.sh-logged-email {
  font-size: 11px;
  color: #16a34a;
  opacity: 0.85;
}
.sh-logged-phone {
  font-size: 11px;
  color: #16a34a;
  opacity: 0.75;
}
.sh-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #166534;
  text-decoration: none;
  border: 1px solid #bbf7d0;
  border-radius: calc(var(--sh-r) * 0.75);
  padding: 4px 10px;
  white-space: nowrap;
  background: #fff;
  transition: background .15s, border-color .15s;
}
.sh-logout-btn:hover {
  background: #dcfce7;
  border-color: #86efac;
  text-decoration: none;
  color: #166534;
}
.sh-logout-btn .material-icons {
  font-size: 14px;
}
.sh-phone-row {
  max-width: 280px;
}

/* ── Error container ─────────────────────────────────────────────── */
.sh-errors {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--sh-r);
  color: #dc2626;
  padding: 10px 14px;
  font-size: 13px;
}
.sh-errors div + div { margin-top: 4px; }

/* ── Carrier choice cards ────────────────────────────────────────── */
.sh-carrier-choices {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.sh-carrier-choice {
  flex: 1;
  min-width: 150px;
  border: 2px solid var(--sh-c3);
  border-radius: var(--sh-r);
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: border-color .15s, box-shadow .15s, background .15s;
  position: relative;
  user-select: none;
  background: #fff;
}

.sh-carrier-choice:hover {
  border-color: var(--sh-c1);
  background: #f0f7ff;
}

.sh-carrier-choice.sh-choice-active {
  border-color: var(--sh-c1);
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}

/* Hidden native radio — we draw our own circle */
.sh-carrier-choice input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* Visible radio circle */
.sh-carrier-choice::before {
  content: '';
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #d1d5db;
  background: #fff;
  flex-shrink: 0;
  transition: border-color .15s, background .15s;
}

.sh-carrier-choice.sh-choice-active::before {
  border-color: var(--sh-c1);
  background: var(--sh-c1);
  box-shadow: inset 0 0 0 4px #fff;
}

.sh-carrier-radio-inner {
  flex: 1;
}

.sh-carrier-name {
  display: block;
  font-weight: 700;
  font-size: 14px;
  color: var(--sh-c4);
}

.sh-carrier-desc {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

/* Carrier price badge shown inside card */
.sh-carrier-price {
  font-size: 12px;
  font-weight: 700;
  color: var(--sh-c1);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 2px 8px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 40px;
  text-align: center;
}

.sh-carrier-choice.sh-choice-active .sh-carrier-price {
  background: var(--sh-c1);
  color: #fff;
  border-color: var(--sh-c1);
}

/* Hide old checkmark — no longer needed */
.sh-carrier-check { display: none !important; }

/* ── Speedy delivery type buttons ────────────────────────────────── */
.sh-deliv-types {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.sh-dtype-btn {
  flex: 1;
  min-width: 100px;
  border: 2px solid #e5e7eb;
  border-radius: var(--sh-r);
  padding: 7px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  transition: border-color .15s, background .15s;
  user-select: none;
}

.sh-dtype-btn input[type="radio"] {
  display: none;
}

.sh-dtype-btn .material-icons {
  font-size: 18px;
  color: #9ca3af;
  transition: color .15s;
}

.sh-dtype-btn:hover {
  border-color: var(--sh-c1);
}

.sh-dtype-btn.active {
  border-color: var(--sh-c1);
  background: var(--sh-c2);
  color: var(--sh-c1);
}

.sh-dtype-btn.active .material-icons {
  color: var(--sh-c1);
}

/* ── City autocomplete ───────────────────────────────────────────── */
.sh-autocomplete-list {
  position: absolute;
  z-index: 1000;
  background: #fff;
  border: 1px solid #d1d5db;
  border-top: none;
  border-radius: 0 0 var(--sh-r) var(--sh-r);
  max-height: 220px;
  overflow-y: auto;
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
}

.sh-form-g {
  position: relative;
}

.sh-autocomplete-list li {
  padding: 9px 14px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background .1s;
}

.sh-autocomplete-list li:last-child { border-bottom: none; }
.sh-autocomplete-list li:hover { background: var(--sh-c2); }
.sh-autocomplete-list li small { color: #9ca3af; margin-left: 4px; }

/* ── Payment ─────────────────────────────────────────────────────── */
.sh-payment-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sh-payment-note {
  font-size: 12px;
  color: #6b7280;
  margin-top: 12px;
  margin-bottom: 0;
}

/* ── Terms checkbox ──────────────────────────────────────────────── */
.sh-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.sh-check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ── Cart summary sidebar ────────────────────────────────────────── */
.sh-cart-summary {
  border: 1px solid var(--sh-c3);
  border-radius: var(--sh-r);
  overflow: hidden;
  position: sticky;
  top: 14px;
}

.sh-cart-head {
  background: var(--sh-c1);
  color: #fff;
  padding: 9px 14px;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  gap: 8px;
}
.sh-cart-head:hover {
  background: color-mix(in srgb, var(--sh-c1) 90%, #000 10%);
}
.sh-cart-head-title {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sh-cart-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  background: rgba(255,255,255,.25);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 800;
  padding: 0 5px;
}
.sh-cart-arrow {
  font-size: 20px;
  transition: transform .2s ease;
}
/* When collapsed the arrow points down — managed via JS textContent change */

.sh-cart-products {
  padding: 8px 14px;
  max-height: 280px;
  overflow-y: auto;
}

.sh-cart-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 12px;
}
.sh-cart-item-link {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.sh-cart-item-link:hover .sh-cart-item-name {
  color: var(--sh-c1);
  text-decoration: underline;
}
.sh-cart-item-img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: calc(var(--sh-r) * 0.5);
  flex-shrink: 0;
  border: 1px solid #e5e7eb;
}

.sh-cart-item:last-child { border-bottom: none; }

.sh-cart-item-name {
  color: var(--sh-c4);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  transition: color .15s;
}

.sh-cart-item-name small {
  color: #9ca3af;
  margin-left: 4px;
}

.sh-cart-item-price {
  font-weight: 600;
  color: var(--sh-c4);
  white-space: nowrap;
}

.sh-cart-total,
.cart-summary-totals .cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 14px;
  background: var(--sh-c2);
  border-top: 1px solid var(--sh-c3);
  font-size: 14px;
  font-weight: 700;
  color: var(--sh-c4);
}

/* Subtotal (products) line */
.sh-cart-subtotal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 14px;
  font-size: 12px;
  color: #4b5563;
  border-top: 1px solid #f0f0f0;
}

/* Shipping line — updated by econt.js / sh-opc.js */
.sh-cart-total.cart-summary-line.shipping {
  font-size: 12px;
  font-weight: 400;
  background: #fff;
  border-top: 1px solid #f0f0f0;
  padding: 6px 14px;
}
.sh-cart-total.cart-summary-line.shipping .value {
  font-weight: 600;
  color: var(--sh-c1);
}

/* econt.js injects breakdown HTML after .value */
.econt-shipping-breakdown-inline {
  font-size: 11px;
  color: #6b7280;
  padding: 3px 14px 6px;
  background: #fff;
  border-bottom: 1px solid var(--sh-c3);
}
.econt-shipping-breakdown-inline .row { display: flex; justify-content: space-between; padding: 1px 0; }
.econt-shipping-breakdown-inline .row.total { font-weight: 700; color: var(--sh-c4); margin-top: 3px; }

/* ── Payment options ─────────────────────────────────────────────── */
.sh-pay-option {
  border: 2px solid #e5e7eb;
  border-radius: var(--sh-r);
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color .15s;
}
.sh-pay-option:has(input:checked) {
  border-color: var(--sh-c1);
}
.sh-pay-label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  margin: 0;
  font-weight: 600;
  font-size: 13px;
  color: var(--sh-c4);
}
.sh-pay-label input[type="radio"] {
  accent-color: var(--sh-c1);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
}
.sh-pay-logo {
  height: 22px;
  width: auto;
  object-fit: contain;
}
.sh-pay-info,
.sh-pay-form {
  padding: 8px 14px 12px;
  border-top: 1px solid #f0f0f0;
  background: #fafafa;
  font-size: 13px;
}

/* ── Invoice section ─────────────────────────────────────────────── */
.sh-invoice-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f0f0f0;
  animation: sh-fadein .18s ease;
}
.sh-invoice-company-fields {
  margin-top: 4px;
}
@keyframes sh-fadein {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Overlay spinner ─────────────────────────────────────────────── */
.sh-spinner {
  width: 38px;
  height: 38px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--sh-c1);
  border-radius: 50%;
  animation: sh-spin .7s linear infinite;
  margin: 0 auto;
}

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

/* ── Carrier panel visibility ────────────────────────────────────── */
/* Use CSS class (not display:none) so embedded widgets stay rendered */
.sh-carrier-panel {
  display: block;
}
.sh-carrier-panel-hidden {
  display: none !important;
}

/* ── Office row (select + map button) ───────────────────────────── */
.sh-office-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.sh-map-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  background: var(--sh-c2);
  border: 2px solid var(--sh-c3);
  border-radius: var(--sh-r);
  color: var(--sh-c1);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  height: 38px;
  transition: background .15s, border-color .15s;
}
.sh-map-btn:hover {
  background: var(--sh-c1);
  border-color: var(--sh-c1);
  color: #fff;
}
.sh-map-btn .material-icons { font-size: 18px; }

/* ── Map modal overlay ───────────────────────────────────────────── */
.sh-map-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.sh-map-dialog {
  background: #fff;
  border-radius: 12px;
  width: min(980px, 96vw);
  height: min(680px, 92vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.sh-map-dialog-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.sh-map-dialog-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--sh-c4);
}
.sh-map-dialog-title .material-icons { color: var(--sh-c1); font-size: 22px; }
.sh-map-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #6b7280;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: background .15s, color .15s;
}
.sh-map-close:hover { background: #f3f4f6; color: var(--sh-c4); }
.sh-map-close .material-icons { font-size: 22px; }
.sh-map-container {
  flex: 1;
  min-height: 0;
}
.sh-map-selected-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: #f0fdf4;
  border-top: 1px solid #bbf7d0;
  font-size: 13px;
  color: #166534;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.sh-map-selected-info .material-icons { color: #16a34a; flex-shrink: 0; }
.sh-map-selected-info span { flex: 1; min-width: 0; }
.sh-map-confirm-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 13px;
}
.sh-map-confirm-btn .material-icons { font-size: 16px; }

/* ── Leaflet custom markers ──────────────────────────────────────── */
.sh-map-marker {
  width: 36px;
  height: 36px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.sh-map-marker .material-icons {
  transform: rotate(45deg);
  font-size: 18px;
  color: #fff;
}
.sh-map-marker-office { background: #e6071a; }
.sh-map-marker-apt    { background: #7c3aed; }
.sh-map-marker-selected { background: #16a34a; width: 40px; height: 40px; }

/* Leaflet popup customisation */
.sh-map-popup .leaflet-popup-content-wrapper {
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  padding: 0;
  overflow: hidden;
}
.sh-map-popup .leaflet-popup-content { margin: 0; }
.sh-map-popup-inner { padding: 12px 14px; min-width: 200px; max-width: 280px; }
.sh-map-popup-inner strong { display: block; font-size: 13px; color: #111827; margin-bottom: 4px; }
.sh-map-popup-addr  { font-size: 12px; color: #6b7280; margin-bottom: 4px; }
.sh-map-popup-hours { font-size: 11px; color: #4b5563; margin-bottom: 8px; }
.sh-map-popup-select {
  width: 100%;
  font-size: 12px;
  padding: 6px 10px;
  background: var(--sh-c1);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}
.sh-map-popup-select:hover { opacity: .9; }

/* ── Unified form field style across ALL three carriers ──────────── */
.sh-opc-wrap .form-control,
.sh-opc-wrap input[type="text"],
.sh-opc-wrap input[type="email"],
.sh-opc-wrap input[type="tel"],
.sh-opc-wrap input[type="number"],
.sh-opc-wrap select,
.sh-sp-field input,
.sh-sp-field select,
.sh-bn-field input,
.sh-bn-field select,
.sh-ec-field input,
.sh-ec-field select,
.sh-ec-field textarea,
.sh-econt-form .form-control,
.sh-econt-form input[type="text"],
.sh-econt-form select,
.sh-econt-form textarea {
  height: 42px;
  border-radius: 6px;
  border: 1.5px solid #d1d5db;
  font-size: 14px;
  color: #1f2937;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  padding: 0 12px;
  width: 100%;
  box-sizing: border-box;
}
/* Textarea needs auto height */
.sh-ec-field textarea,
.sh-econt-form textarea { height: auto; padding: 10px 12px; }

.sh-opc-wrap .form-control:focus,
.sh-opc-wrap input[type="text"]:focus,
.sh-opc-wrap input[type="email"]:focus,
.sh-opc-wrap input[type="tel"]:focus,
.sh-opc-wrap input[type="number"]:focus,
.sh-opc-wrap select:focus,
.sh-sp-field input:focus,
.sh-sp-field select:focus,
.sh-bn-field input:focus,
.sh-bn-field select:focus,
.sh-ec-field input:focus,
.sh-ec-field select:focus,
.sh-ec-field textarea:focus,
.sh-econt-form .form-control:focus,
.sh-econt-form input[type="text"]:focus,
.sh-econt-form select:focus,
.sh-econt-form textarea:focus {
  border-color: var(--sh-c1, #1d4ed8);
  box-shadow: 0 0 0 3px rgba(29,78,216,.12);
  outline: none;
}

/* Unified labels across all three carriers */
.sh-sp-field label,
.sh-bn-field label,
.sh-ec-field label,
.sh-econt-form > label,
.sh-econt-form .sh-ec-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Econt address detail grid (block, entrance, floor etc.) */
.sh-ec-addr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

/* Unified field spacing — all three carriers */
.sh-ec-field,
.sh-sp-field,
.sh-bn-field { margin-bottom: 10px; position: relative; }

/* Econt delivery type buttons — use same .sh-dtype-btn base as Speedy */
.sh-ec-deliv-types { margin-bottom: 4px; }
.sh-ec-deliv-types .sh-dtype-btn.active {
  border-color: var(--sh-c1);
  background: var(--sh-c2);
  color: var(--sh-c1);
}

/* BoxNow focus — same accent as others (no green override) */
.sh-boxnow-autocomplete:focus {
  border-color: var(--sh-c1, #1d4ed8) !important;
  box-shadow: 0 0 0 3px rgba(29,78,216,.12) !important;
}

/* Autocomplete result dropdown */
.sh-sp-city-results,
.sh-econt-form .autocomplete-results {
  border-radius: 0 0 6px 6px;
  border: 1.5px solid var(--sh-c1, #1d4ed8);
  border-top: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.10);
}

/* ── Responsive adjustments ──────────────────────────────────────── */
@media (max-width: 991px) {
  .sh-opc-sidebar {
    margin-top: 20px;
  }
  .sh-cart-summary {
    position: static;
  }
}
