/* ============================================
   Phone Country Picker v2.0 — ShipBob-style
   Unified flag+code inside input field
   Full-screen searchable modal on all devices
   ============================================ */

/* === Unified phone field === */
.pp2 {
  display: flex;
  align-items: center;
  width: 100%;
  border: 1px solid var(--pod-gray-300, #d1d5db);
  border-radius: var(--pod-radius, 8px);
  background: var(--pod-white, #fff);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-height: 44px;
}
.pp2:focus-within {
  border-color: var(--pod-accent, #FDC107);
  box-shadow: 0 0 0 3px rgba(253, 193, 7, 0.15);
}

/* Country trigger button (flag + arrow) */
.pp2-trigger {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 12px;
  height: 100%;
  min-height: 44px;
  border: none;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.pp2-trigger:hover { background: var(--pod-gray-50, #f9fafb); }
.pp2-flag { font-size: 1.35rem; line-height: 1; }
.pp2-arrow { font-size: 0.6rem; color: var(--pod-gray-400, #9ca3af); margin-left: 2px; }

/* Dial code between flag and input */
.pp2-code {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--pod-gray-700, #374151);
  white-space: nowrap;
  padding-right: 8px;
  border-right: 1px solid var(--pod-gray-200, #e5e7eb);
  margin-right: 8px;
  flex-shrink: 0;
  line-height: 44px;
}

/* Phone number input (inside unified field) */
.pp2-input {
  flex: 1;
  border: none !important;
  outline: none !important;
  background: transparent !important;
  padding: 10px 12px 10px 0 !important;
  font-size: 0.95rem !important;
  font-family: inherit;
  color: var(--pod-gray-900, #111827);
  min-width: 0;
  height: auto;
  box-shadow: none !important;
}
.pp2-input::placeholder { color: var(--pod-gray-400, #9ca3af); }

/* Override parent .pod-phone-input flex layout — unified field is the whole thing */
.pod-phone-input {
  display: block !important;
  gap: 0 !important;
}
.pod-phone-input .phone-picker,
.pod-phone-input select.pod-phone-country {
  display: none !important;
}

/* === Overlay + Modal (full-screen on all devices like ShipBob) === */
.pp2-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s;
}
.pp2-overlay.pp2-open {
  opacity: 1;
  visibility: visible;
}

.pp2-modal {
  background: #fff;
  border-radius: 16px;
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0,0,0,0.2);
  transform: translateY(16px) scale(0.97);
  transition: transform 0.25s cubic-bezier(.22,1,.36,1);
}
.pp2-open .pp2-modal {
  transform: translateY(0) scale(1);
}

/* Modal header */
.pp2-modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.pp2-search {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 16px !important; /* Prevent iOS zoom */
  font-family: inherit;
  outline: none;
  background: #f9fafb;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  box-sizing: border-box;
}
.pp2-search:focus {
  border-color: var(--pod-accent, #FDC107);
  background: #fff;
}
.pp2-search::placeholder { color: #9ca3af; }

.pp2-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  border: none;
  background: #f3f4f6;
  border-radius: 50%;
  font-size: 1rem;
  color: #4b5563;
  cursor: pointer;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.pp2-close:hover { background: #e5e7eb; }

/* Country list */
.pp2-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Country item */
.pp2-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.12s;
  border-bottom: 1px solid #f3f4f6;
}
.pp2-item:last-child { border-bottom: none; }
.pp2-item:hover { background: #f9fafb; }
.pp2-item:active { background: #f3f4f6; }
.pp2-item-active { background: #fffbeb; }
.pp2-item-active:hover { background: #fef9c3; }

.pp2-item-flag { font-size: 1.4rem; line-height: 1; flex-shrink: 0; }
.pp2-item-name {
  flex: 1;
  font-size: 0.95rem;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pp2-item-code {
  font-size: 0.85rem;
  color: #6b7280;
  font-weight: 500;
  flex-shrink: 0;
}

/* === Mobile (≤ 600px): full-screen modal like ShipBob === */
@media (max-width: 600px) {
  .pp2-modal {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    transform: translateY(100%);
  }
  .pp2-open .pp2-modal {
    transform: translateY(0);
  }
  .pp2-overlay {
    align-items: stretch;
  }
  .pp2-modal-header {
    padding: 12px 12px;
    padding-top: max(12px, env(safe-area-inset-top, 12px));
  }
  .pp2-item {
    padding: 14px 16px;
  }
  .pp2-item-flag { font-size: 1.5rem; }
  .pp2-item-name { font-size: 1rem; }
  .pp2-item-code { font-size: 0.9rem; }
  .pp2-list {
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .pp2-trigger { padding: 0 6px 0 10px; }
  .pp2-code { font-size: 0.85rem; padding-right: 6px; margin-right: 6px; }
  .pp2-input { font-size: 16px !important; } /* iOS zoom prevention */
}

/* === Tablet (601–768px) === */
@media (min-width: 601px) and (max-width: 768px) {
  .pp2-modal { width: 380px; }
}

/* === Accessibility: reduced motion === */
@media (prefers-reduced-motion: reduce) {
  .pp2-overlay, .pp2-modal { transition: none !important; }
}
