/* Optimized International Telephone Input CSS */
/* Base styles for the input container */
.intl-tel-input {
  position: relative;
  display: inline-block;
  width: 100%;
}

.intl-tel-input.allow-dropdown {
  position: relative;
}

.intl-tel-input.separate-dial-code {
  position: relative;
}

/* Flag container */
.flag-container {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  padding: 1px;
}

/* Selected flag */
.selected-flag {
  z-index: 1;
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
  padding: 0 10px;
  outline: none;
  border: none;
  cursor: pointer;
}


/* Flag image */
.iti-flag {
  width: 20px;
  height: 15px;
  background-repeat: no-repeat;
  background-position: center;
  display: inline-block;
  margin-right: 6px;
}

/* Individual flag classes - loaded dynamically */

/* Dial code display */
.selected-dial-code {
  font-size: 14px;
  color: #495057;
  margin-left: 4px;
}

/* Dropdown arrow */
.iti-arrow {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid #6c757d;
  margin-left: 4px;
  transition: transform 0.2s ease;
}

.iti-arrow.up {
  transform: rotate(180deg);
}

/* Country list dropdown */
.country-list {
  max-width: 300px;
  position: absolute;
  z-index: 9999;
  list-style: none;
  text-align: left;
  padding: 0;
  margin: 0 0 0 -1px;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.2);
  background-color: #fff;
  border: 1px solid #ccc;
  white-space: nowrap;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
}

.country-list.hide {
  display: none;
}

.country-list.dropup {
  top: auto;
  bottom: 100%;
  border-top: 1px solid #ced4da;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
}

/* Country list items */
.country-list li {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #f8f9fa;
}

.country-list li:last-child {
  border-bottom: none;
}

.country-list li:hover,
.country-list li.highlight {
  background: #f8f9fa;
}

.country-list li.active {
  background: #007bff;
  color: white;
}

/* Flag box in dropdown */
.flag-box {
  width: 20px;
  height: 15px;
  margin-right: 8px;
  display: flex;
  align-items: center;
}

.flag-box .iti-flag {
  margin-right: 0;
}

/* Country name and dial code in dropdown */
.country-name {
  flex: 1;
  font-size: 14px;
  color: #495057;
}

.dial-code {
  font-size: 14px;
  color: #6c757d;
  margin-left: 8px;
}

/* Divider */
.divider {
  height: 1px;
  background: #dee2e6;
  margin: 4px 0;
  cursor: default;
}

/* Input field */
.intl-tel-input input,
.intl-tel-input input[type="tel"],
.intl-tel-input input[type="text"] {
  position: relative;
  z-index: 0;
  margin: 0;
  padding-left: 36px;
  padding-right: 12px;
  width: 100%;
  border: 1px solid #ced4da;
  border-radius: 4px;
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: 14px;
  outline: none;
}

.intl-tel-input input[type="tel"]:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}


/* Mobile styles */
.iti-mobile .country-list {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: none;
  border: none;
  border-radius: 0;
  z-index: 9999;
}

.iti-mobile .country-list li {
  padding: 12px 16px;
  font-size: 16px;
}

/* Loading state for flags */
.iti-flag.loading {
  background-image: none;
  background-color: #f8f9fa;
  position: relative;
}

.iti-flag.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border: 2px solid #007bff;
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Fallback for missing flags */
.iti-flag.missing {
  background-image: none;
  background-color: #e9ecef;
  position: relative;
}

.iti-flag.missing::after {
  content: '?';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  color: #6c757d;
  font-weight: bold;
}
