/**
 * GRC International Phone Input Component Styles
 * Responsive, accessible phone input with country selector
 */

.grc-phone-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
  width: 100%;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
}

.grc-phone-wrapper:focus-within {
  border-color: #059669;
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
  outline: none;
}

/* Country selector button */
.grc-phone-country-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0 0.75rem;
  background: #f9fafb;
  border: none;
  border-right: 1px solid #d1d5db;
  cursor: pointer;
  transition: background-color 0.15s ease;
  flex-shrink: 0;
}

.grc-phone-country-btn:hover {
  background: #f3f4f6;
}

.grc-phone-country-btn:focus {
  outline: none;
  background: #e5e7eb;
}

.grc-phone-flag {
  font-size: 1.25rem;
  line-height: 1;
}

.grc-phone-chevron {
  font-size: 0.625rem;
  color: #6b7280;
  transition: transform 0.2s ease;
}

.grc-phone-dropdown.open + * + .grc-phone-country-btn .grc-phone-chevron {
  transform: rotate(180deg);
}

/* Dial code prefix display */
.grc-phone-prefix {
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  background: #f9fafb;
  border-right: 1px solid #d1d5db;
  user-select: none;
  flex-shrink: 0;
}

/* Phone input field */
.grc-phone-input-field {
  flex: 1;
  padding: 0.625rem 0.75rem;
  border: none;
  outline: none;
  background: transparent;
  font-size: 0.875rem;
  color: #111827;
  min-width: 0;
}

.grc-phone-input-field::placeholder {
  color: #9ca3af;
}

/* Dropdown container */
.grc-phone-dropdown {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  z-index: 1000;
  display: none;
  flex-direction: column;
  max-height: 20rem;
  overflow: hidden;
}

.grc-phone-dropdown.open {
  display: flex;
}

/* Search input */
.grc-phone-search {
  padding: 0.75rem;
  border: none;
  border-bottom: 1px solid #e5e7eb;
  outline: none;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.grc-phone-search:focus {
  border-bottom-color: #059669;
}

.grc-phone-search::placeholder {
  color: #9ca3af;
}

/* Country list */
.grc-phone-country-list {
  overflow-y: auto;
  flex: 1;
}

.grc-phone-country-list::-webkit-scrollbar {
  width: 0.5rem;
}

.grc-phone-country-list::-webkit-scrollbar-track {
  background: #f9fafb;
}

.grc-phone-country-list::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 0.25rem;
}

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

/* Country item */
.grc-phone-country-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border: none;
  background: transparent;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background-color 0.1s ease;
}

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

.grc-phone-country-item:focus {
  outline: none;
  background: #e5e7eb;
}

.grc-phone-country-item.selected {
  background: #ecfdf5;
  color: #059669;
}

.grc-phone-country-item.selected:hover {
  background: #d1fae5;
}

.grc-phone-country-name {
  flex: 1;
  font-size: 0.875rem;
  color: #374151;
}

.grc-phone-country-item.selected .grc-phone-country-name {
  font-weight: 500;
  color: #059669;
}

.grc-phone-country-dial {
  font-size: 0.875rem;
  color: #6b7280;
  font-weight: 500;
}

.grc-phone-country-item.selected .grc-phone-country-dial {
  color: #047857;
}

/* No results message */
.grc-phone-no-results {
  padding: 1rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.875rem;
}

/* Dark background support */
.bg-gray-900 .grc-phone-wrapper,
.bg-gray-800 .grc-phone-wrapper,
[class*="bg-emerald-"] .grc-phone-wrapper {
  background: white;
  border-color: #d1d5db;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .grc-phone-country-btn {
    padding: 0 0.5rem;
  }

  .grc-phone-prefix {
    padding: 0 0.375rem;
    font-size: 0.8125rem;
  }

  .grc-phone-input-field {
    padding: 0.5rem 0.625rem;
    font-size: 0.8125rem;
  }

  .grc-phone-dropdown {
    max-height: 16rem;
  }

  .grc-phone-country-name {
    font-size: 0.8125rem;
  }

  .grc-phone-country-dial {
    font-size: 0.8125rem;
  }
}

/* Accessibility - keyboard focus visible */
.grc-phone-country-btn:focus-visible {
  outline: 2px solid #059669;
  outline-offset: 2px;
}

.grc-phone-country-item:focus-visible {
  outline: 2px solid #059669;
  outline-offset: -2px;
}

/* Error state support */
.grc-phone-wrapper.error {
  border-color: #ef4444;
}

.grc-phone-wrapper.error:focus-within {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Disabled state */
.grc-phone-wrapper.disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.grc-phone-wrapper.disabled .grc-phone-country-btn,
.grc-phone-wrapper.disabled .grc-phone-input-field {
  cursor: not-allowed;
  background: #f3f4f6;
}

/* Animation */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-0.5rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.grc-phone-dropdown.open {
  animation: slideDown 0.15s ease;
}
