/* Smart Delivery Location Picker — direction comes from the dir="rtl|ltr" attribute printed by PHP (is_rtl()). */
.wplp-hidden { display: none !important; }
html.wplp-modal-open { overflow: hidden; }

/* ---------- floating button ---------- */
.wplp-header-wrap {
  position: fixed; left: 16px; bottom: 16px; z-index: 99990;
  display: flex; align-items: center; gap: 4px;
  max-width: calc(100vw - 32px); touch-action: none;
}
.wplp-header-location {
  display: inline-flex; align-items: center; gap: 6px; max-width: 260px;
  padding: 10px 14px; border: 0; border-radius: 999px; cursor: pointer;
  background: #1f2937; color: #fff; font: inherit; font-size: 13px; line-height: 1.3;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25); touch-action: none; user-select: none;
}
.wplp-header-location:hover { background: #111827; }
.wplp-has-location .wplp-header-location { background: var(--wplp-accent, #047857); }
.wplp-header-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wplp-header-close {
  width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 15px; line-height: 22px; cursor: pointer;
}
.wplp-style-circle .wplp-header-location { width: 52px; height: 52px; padding: 0; justify-content: center; border-radius: 50%; }
.wplp-style-circle .wplp-header-text { display: none; }
.wplp-style-circle .wplp-pin { font-size: 22px; }

/* ---------- modal ---------- */
.wplp-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 99998; }
.wplp-backdrop[hidden], .wplp-modal[hidden] { display: none; }
.wplp-modal {
  position: fixed; z-index: 99999; text-align: start;
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  /* --wplp-vh = the REAL visible height (set by JS). 100vh on many mobile browsers is taller than the
     visible area (URL bar / toolbars), which pushed the confirm button off-screen. */
  max-height: calc(var(--wplp-vh, 100vh) - 24px);
  display: flex; flex-direction: column; background: #fff; color: #111827;
  border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); overflow: hidden;
}
.wplp-modal-head { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #e5e7eb; }
.wplp-modal-head h2 { margin: 0; font-size: 17px; }
.wplp-close { border: 0; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: #6b7280; }
.wplp-modal-body { flex: 1 1 auto; min-height: 0; padding: 12px 16px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.wplp-modal-foot { flex: 0 0 auto; padding: 12px 16px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid #e5e7eb; }

.wplp-search-row { display: flex; gap: 6px; }
.wplp-search-row input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; }
.wplp-btn { padding: 9px 14px; border: 1px solid #d1d5db; border-radius: 8px; background: #f3f4f6; color: #111827; font: inherit; cursor: pointer; }
.wplp-btn:hover { background: #e5e7eb; }
.wplp-btn-primary { width: 100%; background: var(--wplp-accent, #047857); border-color: var(--wplp-accent, #047857); color: #fff; font-weight: 600; padding: 12px; }
.wplp-btn-primary:hover { background: var(--wplp-accent-dark, #065f46); }
.wplp-btn-primary:disabled { background: #9ca3af; border-color: #9ca3af; cursor: not-allowed; }
.wplp-status-line { min-height: 18px; margin: 4px 0; font-size: 12px; color: #6b7280; }
.wplp-results { list-style: none; margin: 0 0 8px; padding: 0; border: 1px solid #e5e7eb; border-radius: 8px; max-height: 190px; overflow-y: auto; }
.wplp-results[hidden] { display: none; }
.wplp-results li + li { border-top: 1px solid #f3f4f6; }
.wplp-results button { display: block; width: 100%; padding: 9px 12px; border: 0; background: #fff; text-align: start; font: inherit; font-size: 13px; cursor: pointer; }
.wplp-results button:hover { background: #f9fafb; }

.wplp-map, .wplp-checkout-map { width: 100%; height: 300px; border-radius: 10px; background: #e5e7eb; z-index: 0; }
.wplp-checkout-map { height: 190px; margin-bottom: 8px; }
.wplp-route-info { min-height: 18px; margin: 6px 0; font-size: 12px; color: #374151; }

.wplp-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; margin-top: 8px; }
.wplp-field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #4b5563; }
.wplp-field input { padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; font-size: 14px; color: #111827; background: #fff; }
.wplp-field input:focus { outline: 2px solid var(--wplp-accent, #047857); outline-offset: 0; }
.wplp-field input[readonly] { background: #f3f4f6; }
.wplp-address { margin-top: 10px; padding: 9px 12px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 8px; font-size: 13px; min-height: 20px; }
.wplp-address:empty { display: none; }
.wplp-status { margin-top: 8px; font-size: 13px; }
.wplp-status-info { color: #1d4ed8; }
.wplp-status-warn { color: #b45309; }
.wplp-status-error { color: #b91c1c; }
.wplp-note { margin: 6px 0; padding: 8px 10px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; font-size: 12px; color: #92400e; }
.wplp-note[hidden] { display: none; }

.wplp-inline-btn { padding: 9px 14px; border: 1px solid var(--wplp-accent, #047857); border-radius: 8px; background: #fff; color: var(--wplp-accent, #047857); font: inherit; cursor: pointer; }
.wplp-inline-btn:hover { background: #ecfdf5; }

/* ---------- checkout ---------- */
.wplp-checkout-location { clear: both; margin: 16px 0; padding: 14px; border: 1px solid #e5e7eb; border-radius: 12px; background: #fafafa; }
.wplp-checkout-location h3 { margin: 0 0 10px; font-size: 16px; }
.wplp-checkout-location [hidden] { display: none; }
/* Progressive enhancement: WooCommerce's own city / address_1 rows are hidden
   only while the plugin panel is active and holds the values. */
form.checkout.wplp-active #billing_city_field,
form.checkout.wplp-active #shipping_city_field,
form.checkout.wplp-active #billing_address_1_field,
form.checkout.wplp-active #shipping_address_1_field { display: none !important; }

@media (max-width: 560px) {
  .wplp-modal {
    width: 100%; top: 0; left: 0; transform: none; border-radius: 0;
    height: 100vh; max-height: 100vh;
    height: 100dvh; max-height: 100dvh;                               /* modern browsers */
    height: var(--wplp-vh, 100vh); max-height: var(--wplp-vh, 100vh); /* exact visible height from JS */
  }
  .wplp-map { height: 240px; }
  .wplp-form { grid-template-columns: 1fr 1fr; }
  .wplp-header-location { max-width: 200px; }
}
.leaflet-container { font-family: inherit; }

/* ---------- [wplp_location] shortcode (mirrors the floating button) ---------- */
.wplp-sc { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.wplp-sc .wplp-loc-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wplp-sc-button.wplp-has-location { border-color: var(--wplp-accent, #047857); background: #ecfdf5; }
.wplp-sc-pill {
  padding: 10px 14px; border: 0; border-radius: 999px; cursor: pointer;
  background: #1f2937; color: #fff; font: inherit; font-size: 13px; line-height: 1.3;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.wplp-sc-pill:hover { background: #111827; color: #fff; }
.wplp-sc-pill.wplp-has-location { background: var(--wplp-accent, #047857); }
.wplp-sc-link { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; }
.wplp-sc-link:hover { background: transparent; text-decoration: none; }

/* ---------- center-pin picking mode ---------- */
.wplp-map-wrap { position: relative; }
.wplp-center-pin { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: 500; pointer-events: none; }
.wplp-center-pin[hidden] { display: none; }
.wplp-center-pin-icon {
  position: absolute; left: -14px; top: -34px; width: 28px; height: 28px;
  background: #dc2626; border: 2px solid #fff; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); transition: transform .15s ease; box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}
.wplp-center-pin-icon::after { content: ""; position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; margin: -4px 0 0 -4px; background: #fff; border-radius: 50%; }
.wplp-center-pin-shadow { position: absolute; left: -5px; top: -2px; width: 10px; height: 4px; background: rgba(0, 0, 0, .35); border-radius: 50%; transition: transform .15s ease, opacity .15s ease; }
.wplp-center-pin.wplp-lifting .wplp-center-pin-icon { transform: translateY(-8px) rotate(-45deg); }
.wplp-center-pin.wplp-lifting .wplp-center-pin-shadow { transform: scale(.6); opacity: .5; }
.wplp-pin-hint { margin: 6px 0 0; font-size: 12px; color: #4b5563; }
.wplp-pin-hint[hidden] { display: none; }

/* ---------- courier fields ---------- */
.wplp-field-wide { grid-column: 1 / -1; }
.wplp-field textarea { padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; font-size: 14px; color: #111827; background: #fff; resize: vertical; }
.wplp-field textarea:focus { outline: 2px solid var(--wplp-accent, #047857); outline-offset: 0; }

/* ---------- delivery cost (zones) ---------- */
.wplp-quote { margin-top: 8px; padding: 8px 12px; border-radius: 8px; font-size: 13px; background: #eff6ff; border: 1px solid #bfdbfe; color: #1e3a8a; }
.wplp-quote-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; font-weight: 600; }
.wplp-quote-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.wplp-quote[hidden] { display: none; }

/* ---------- icons ---------- */
.wplp-ico { display: inline-block; vertical-align: -3px; flex: 0 0 auto; }
.wplp-pin { display: inline-flex; align-items: center; }
.wplp-btn-light { display: inline-flex; align-items: center; justify-content: center; }

/* ---------- "use my location": a full-width button on touch screens, the small icon on desktop ---------- */
.wplp-locate-wide {
  display: none; align-items: center; justify-content: center; gap: 8px; width: 100%; margin: 6px 0 2px; padding: 11px 14px;
  border: 1px solid var(--wplp-accent, #047857); border-radius: 10px; background: #fff; color: var(--wplp-accent, #047857);
  font: inherit; font-weight: 600; cursor: pointer;
}
@media (pointer: coarse) {
  .wplp-locate-wide { display: flex; }
  .wplp-search-row #wplp-geolocate { display: none; }
}

/* ---------- saved addresses ---------- */
.wplp-book { margin: 8px 0 4px; }
.wplp-book[hidden] { display: none; }
.wplp-book-title { display: block; margin-bottom: 4px; font-size: 12px; color: #6b7280; }
.wplp-book-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.wplp-book-list li { display: inline-flex; align-items: stretch; border: 1px solid #d1d5db; border-radius: 999px; overflow: hidden; background: #fff; }
.wplp-chip { padding: 6px 12px; border: 0; background: transparent; color: #111827; font: inherit; font-size: 13px; cursor: pointer; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wplp-chip:hover { background: #f3f4f6; }
.wplp-chip-x { padding: 0 9px; border: 0; border-inline-start: 1px solid #e5e7eb; background: transparent; color: #9ca3af; font-size: 15px; cursor: pointer; }
.wplp-chip-x:hover { background: #fef2f2; color: #b91c1c; }
.wplp-book-name { margin-top: 10px; }

/* ---------- loading state ---------- */
.wplp-resolving .wplp-form input { background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 37%, #f3f4f6 63%); background-size: 400% 100%; animation: wplp-shimmer 1.2s ease infinite; }
@keyframes wplp-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- accessibility ---------- */
.wplp-btn:focus-visible, .wplp-header-location:focus-visible, .wplp-inline-btn:focus-visible, .wplp-chip:focus-visible,
.wplp-chip-x:focus-visible, .wplp-close:focus-visible, .wplp-results button:focus-visible, .wplp-locate-wide:focus-visible {
  outline: 2px solid var(--wplp-accent, #047857); outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  .wplp-center-pin-icon, .wplp-center-pin-shadow { transition: none; }
  .wplp-resolving .wplp-form input { animation: none; }
}

/* ---------- customer order page ---------- */
.wplp-order-block { margin-top: 24px; }
.wplp-order-block address { font-style: normal; line-height: 1.6; }
