/* International Phone Selector Styles */

.intl-phone-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

/* Override rounded borders for wrapped inputs */
.intl-phone-wrapper > input[type="tel"] {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
  flex: 1;
  min-width: 0;
}

.intl-phone-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 8px 12px;
  border: 1px solid #d1d5db;
  border-right: none;
  border-radius: 0.5rem 0 0 0.5rem;
  background: #f9fafb;
  cursor: pointer;
  white-space: nowrap;
  align-self: stretch;
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.intl-phone-btn:hover {
  background: #f3f4f6;
  border-color: #9ca3af;
}

.intl-phone-btn:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.intl-phone-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}

.intl-phone-flag img {
  display: block;
  border-radius: 2px;
}

.intl-phone-code {
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  font-family: monospace;
  margin-right: 2px;
}

.intl-phone-arrow {
  font-size: 10px;
  color: #9ca3af;
}

/* Dropdown */
.intl-phone-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  margin-top: 4px;
  overflow: hidden;
}

.intl-phone-search-wrap {
  padding: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.intl-phone-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.intl-phone-search:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.intl-phone-list {
  max-height: 250px;
  overflow-y: auto;
  padding: 4px 0;
}

.intl-phone-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
  font-size: 14px;
}

.intl-phone-item:hover {
  background: #f3f4f6;
}

.intl-phone-item.selected {
  background: #eef2ff;
  font-weight: 500;
}

.intl-phone-item-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}

.intl-phone-item-flag img {
  display: block;
  border-radius: 2px;
}

.intl-phone-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #111827;
}

.intl-phone-item-code {
  font-family: monospace;
  font-size: 13px;
  color: #6b7280;
  flex-shrink: 0;
}

.intl-phone-empty {
  padding: 16px;
  text-align: center;
  color: #9ca3af;
  font-size: 14px;
}

/* Scrollbar styling */
.intl-phone-list::-webkit-scrollbar {
  width: 6px;
}

.intl-phone-list::-webkit-scrollbar-track {
  background: transparent;
}

.intl-phone-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.intl-phone-list::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Dark mode */
.dark .intl-phone-btn,
[data-theme="dark"] .intl-phone-btn {
  background: #374151;
  border-color: #4b5563;
  color: #e5e7eb;
}

.dark .intl-phone-btn:hover,
[data-theme="dark"] .intl-phone-btn:hover {
  background: #4b5563;
  border-color: #6b7280;
}

.dark .intl-phone-code,
[data-theme="dark"] .intl-phone-code {
  color: #d1d5db;
}

.dark .intl-phone-dropdown,
[data-theme="dark"] .intl-phone-dropdown {
  background: #1f2937;
  border-color: #4b5563;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.dark .intl-phone-search-wrap,
[data-theme="dark"] .intl-phone-search-wrap {
  border-bottom-color: #374151;
}

.dark .intl-phone-search,
[data-theme="dark"] .intl-phone-search {
  background: #374151;
  border-color: #4b5563;
  color: #e5e7eb;
}

.dark .intl-phone-search:focus,
[data-theme="dark"] .intl-phone-search:focus {
  border-color: #6366f1;
}

.dark .intl-phone-item:hover,
[data-theme="dark"] .intl-phone-item:hover {
  background: #374151;
}

.dark .intl-phone-item.selected,
[data-theme="dark"] .intl-phone-item.selected {
  background: #312e81;
}

.dark .intl-phone-item-name,
[data-theme="dark"] .intl-phone-item-name {
  color: #e5e7eb;
}

.dark .intl-phone-item-code,
[data-theme="dark"] .intl-phone-item-code {
  color: #9ca3af;
}

.dark .intl-phone-empty,
[data-theme="dark"] .intl-phone-empty {
  color: #6b7280;
}

/* Responsive: smaller screens */
@media (max-width: 480px) {
  .intl-phone-dropdown {
    width: calc(100vw - 32px);
    left: -12px;
  }
  
  .intl-phone-code {
    font-size: 12px;
  }
  
  .intl-phone-btn {
    padding: 8px 6px 8px 8px;
  }
}

/* Match rounded-xl inputs (marketplace) - applied via JS class */
.intl-phone-wrapper.intl-phone-rounded .intl-phone-btn {
  border-radius: 0.75rem 0 0 0.75rem;
}

/* Match border color of sibling input */
.intl-phone-wrapper > input.border-slate-200 ~ .intl-phone-btn,
.intl-phone-wrapper.intl-phone-slate-border .intl-phone-btn {
  border-color: #e2e8f0;
}

/* ===== Notification bubble (auto-correction feedback) ===== */
.intl-phone-notif {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  padding: 6px 10px;
  background: #fefce8;
  border: 1px solid #fbbf24;
  border-radius: 6px;
  font-size: 12px;
  color: #92400e;
  z-index: 10;
  animation: intlPhoneNotifIn 0.2s ease-out;
  line-height: 1.4;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  pointer-events: none;
}
.intl-phone-notif::before {
  content: '\26A0\FE0F';
  margin-right: 4px;
}
@keyframes intlPhoneNotifIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Validation error */
.intl-phone-error {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  padding: 4px 10px;
  font-size: 12px;
  color: #dc2626;
  line-height: 1.4;
}
.intl-phone-error::before {
  content: '\2716';
  margin-right: 4px;
  font-size: 10px;
}

/* Invalid state border */
.intl-phone-wrapper.intl-phone-invalid > input[type="tel"] {
  border-color: #ef4444 !important;
}
.intl-phone-wrapper.intl-phone-invalid .intl-phone-btn {
  border-color: #ef4444 !important;
}

/* Ensure wrapper has relative positioning for notifications */
/* (already set in base .intl-phone-wrapper rule above) */

/* Dark mode for notifications and errors */
.dark .intl-phone-notif,
[data-theme="dark"] .intl-phone-notif {
  background: #422006;
  border-color: #b45309;
  color: #fde68a;
}

.dark .intl-phone-error,
[data-theme="dark"] .intl-phone-error {
  color: #fca5a5;
}
