/* Phone Input Component — RTL-aware */

.phone-input-group {
  width: 100%;
}

.phone-input-wrapper {
  display: flex;
  direction: ltr; /* phone numbers are always LTR */
  align-items: stretch;
  border: 1px solid #ced4da;
  border-radius: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}

.phone-input-wrapper:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* Country selector button */
.phone-country-select {
  position: relative;
  flex-shrink: 0;
}

.phone-country-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: none;
  background: #f8f9fa;
  cursor: pointer;
  height: 100%;
  font-size: 14px;
  color: #333;
  border-right: 1px solid #e2e8f0;
  border-radius: 8px 0 0 8px;
  white-space: nowrap;
  transition: background 0.15s;
}

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

.phone-flag {
  font-size: 20px;
  line-height: 1;
}

.phone-code {
  font-family: monospace;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
}

.phone-chevron {
  font-size: 10px;
  color: #94a3b8;
  transition: transform 0.2s;
}

/* Number input */
.phone-number-input {
  flex: 1;
  border: none !important;
  border-radius: 0 8px 8px 0 !important;
  box-shadow: none !important;
  outline: none !important;
  font-size: 15px;
  padding: 8px 12px;
  direction: ltr;
  text-align: left;
  font-family: monospace;
  letter-spacing: 0.5px;
  min-width: 0;
}

.phone-number-input:focus {
  box-shadow: none !important;
  border: none !important;
}

.phone-number-input::placeholder {
  color: #cbd5e1;
  letter-spacing: 1px;
}

/* Dropdown */
.phone-country-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  width: 280px;
  max-height: 300px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 99999;
  overflow: hidden;
}

.phone-country-dropdown.open {
  display: block;
}

/* Search inside dropdown */
.phone-country-search {
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid #e2e8f0;
  font-size: 14px;
  outline: none;
  direction: rtl;
}

.phone-country-search::placeholder {
  color: #94a3b8;
}

/* Country list */
.phone-country-list {
  max-height: 240px;
  overflow-y: auto;
}

.phone-country-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background 0.1s;
  direction: rtl;
}

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

.phone-country-item-flag {
  font-size: 20px;
  flex-shrink: 0;
}

.phone-country-item-name {
  flex: 1;
  font-size: 14px;
  color: #334155;
}

.phone-country-item-dial {
  font-family: monospace;
  font-size: 13px;
  color: #64748b;
  direction: ltr;
}

/* Readonly state */
.phone-input-group[data-readonly="true"] .phone-country-btn {
  cursor: default;
  pointer-events: none;
}

.phone-input-group[data-readonly="true"] .phone-chevron {
  display: none;
}

.phone-input-group[data-readonly="true"] .phone-number-input {
  background: #f8f9fa;
  cursor: default;
}

/* Small variant (for forms inside modals etc.) */
.phone-input-wrapper.phone-input-sm .phone-country-btn {
  padding: 5px 8px;
  font-size: 13px;
}

.phone-input-wrapper.phone-input-sm .phone-flag {
  font-size: 17px;
}

.phone-input-wrapper.phone-input-sm .phone-number-input {
  padding: 5px 10px;
  font-size: 14px;
}

/* Inside Bootstrap modals — ensure dropdown is above modal */
.modal .phone-country-dropdown {
  z-index: 100060;
}

/* Responsive — make dropdown span the full wrapper width on small screens */
@media (max-width: 768px) {
  .phone-input-wrapper {
    position: relative;
  }
  .phone-country-select {
    position: static;
  }
  .phone-country-dropdown {
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
  }
}

@media (max-width: 400px) {
  .phone-country-btn {
    padding: 8px 6px;
    gap: 4px;
  }
  .phone-code {
    font-size: 12px;
  }
}

/* Dark theme compatibility (if used) */
.phone-input-wrapper.phone-dark {
  background: #1e293b;
  border-color: #334155;
}

.phone-dark .phone-country-btn {
  background: #0f172a;
  border-right-color: #334155;
  color: #e2e8f0;
}

.phone-dark .phone-country-btn:hover {
  background: #1e293b;
}

.phone-dark .phone-number-input {
  background: #1e293b;
  color: #f1f5f9;
}

.phone-dark .phone-country-dropdown {
  background: #1e293b;
  border-color: #334155;
}

.phone-dark .phone-country-item:hover {
  background: #334155;
}

.phone-dark .phone-country-search {
  background: #0f172a;
  color: #e2e8f0;
  border-bottom-color: #334155;
}
