/* Enhanced Popup Styles */
.popup {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s cubic-bezier(0.19, 1, 0.22, 1), visibility 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

.popup.active {
  opacity: 1;
  visibility: visible;
}

.popup-content {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 40px;
  width: 100%;
  max-width: 550px;
  position: relative;
  box-shadow: 0 15px 50px rgba(0, 0, 0, 0.15);
  transform: translateY(30px) scale(0.95);
  transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
  overflow: hidden;
}

.popup.active .popup-content {
  transform: translateY(0) scale(1);
}

/* Decorative elements */
.popup-content::before {
  content: "";
  position: absolute;
  top: -100px;
  right: -100px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue_50), var(--blue_100));
  opacity: 0.3;
  z-index: -1;
}

.popup-content::after {
  content: "";
  position: absolute;
  bottom: -80px;
  left: -80px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple_100), var(--teal_a400));
  opacity: 0.2;
  z-index: -1;
}

.popup-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: transparent;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: pointer;
  color: var(--gray_600);
  transition: all 0.3s ease;
  z-index: 5;
}

.popup-close:hover {
  color: var(--black_900);
  background-color: rgba(0, 0, 0, 0.05);
  transform: rotate(90deg);
}

.popup-title {
  margin-bottom: 10px;
  font-size: 32px;
  color: transparent;
  background: linear-gradient(135deg, var(--black_900), var(--indigo_900));
  background-clip: text;
  -webkit-background-clip: text;
  line-height: 1.2;
}

.popup-subtitle {
  color: var(--gray_600);
  margin-bottom: 30px;
  font-size: 16px;
  line-height: 1.5;
  max-width: 90%;
}

/* Form styles */
.popup-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  transition: all 0.3s ease;
}

.form-group label {
  font-weight: 500;
  font-size: 14px;
  color: var(--gray_900);
  transition: color 0.3s ease;
}

.form-control {
  padding: 15px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  font-size: 16px;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.8);
}

.form-control:focus {
  border-color: var(--gray_600);
  outline: none;
  box-shadow: 0 0 0 3px rgba(123, 123, 123, 0.1);
  background: white;
}

.form-group:focus-within label {
  color: var(--gray_600);
}

/* Select styling */
select.form-control {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%237b7b7b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 15px center;
  background-size: 16px;
  padding-right: 45px;
  color: var(--gray_600);
}

select.form-control option {
  color: var(--black_900);
  background-color: white;
}

select.form-control option:first-child {
  color: var(--gray_600);
}

/* Ensure only one arrow shows up when select is focused */
select.form-control:focus {
  /* Remove default background image to avoid stacking */
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%237b7b7b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
  border-color: var(--gray_600);
  box-shadow: 0 0 0 3px rgba(123, 123, 123, 0.1);
}

/* Remove any browser-added background images or effects */
select.form-control::-ms-expand {
  display: none;
}

select.form-control:-moz-focusring {
  color: transparent;
  text-shadow: 0 0 0 var(--black_900);
}

/* Override any browser default styling */
select.form-control:-webkit-autofill,
select.form-control:-webkit-autofill:hover,
select.form-control:-webkit-autofill:focus {
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%237b7b7b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
  background-repeat: no-repeat !important;
  background-position: right 15px center !important;
  background-size: 16px !important;
}

/* Remove blue outline on focus */
select.form-control:focus-visible {
  outline: none;
}

/* Styling for when an option is selected */
select.form-control:not([value=""]):not(:focus) {
  color: var(--black_900);
}

/* Checkbox styling */
.form-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 5px 0;
}

.form-checkbox input[type="checkbox"] {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  display: grid;
  place-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.form-checkbox input[type="checkbox"]::before {
  content: "";
  width: 12px;
  height: 12px;
  transform: scale(0);
  transition: transform 0.15s ease-in-out;
  box-shadow: inset 1em 1em var(--blue_900);
  transform-origin: center;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

.form-checkbox input[type="checkbox"]:checked {
  background-color: var(--black_900);
  border-color: var(--black_900);
}

.form-checkbox input[type="checkbox"]:checked::before {
  transform: scale(1);
  background-color: white;
}

.form-checkbox input[type="checkbox"]:focus {
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

.form-checkbox label {
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray_600);
  user-select: none;
}

/* Textarea styling */
textarea.form-control {
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

/* Submit button */
.form-submit {
  background: linear-gradient(135deg, var(--black_900), var(--gray_900_01));
  color: var(--white_a700);
  padding: 15px 25px;
  border: none;
  border-radius: 12px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 15px;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.form-submit::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--gray_900_01), var(--gray_600));
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.form-submit:hover::before {
  opacity: 1;
}

.form-submit:active {
  transform: translateY(2px);
}

/* Two column layout for shorter forms */
.form-row {
  display: flex;
  gap: 20px;
}

.form-row .form-group {
  flex: 1;
}

/* Form field success/error states */
.form-group.success .form-control {
  border-color: #4CAF50;
}

.form-group.error .form-control {
  border-color: #F44336;
}

.field-message {
  font-size: 12px;
  margin-top: 5px;
  line-height: 1.2;
}

.field-message.error {
  color: #F44336;
}

.field-message.success {
  color: #4CAF50;
}

/* Progress indicator for form steps */
.form-progress {
  display: flex;
  justify-content: space-between;
  margin-bottom: 30px;
  position: relative;
}

.form-progress::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--gray_400);
  transform: translateY(-50%);
  z-index: 1;
}

.progress-step {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: white;
  border: 2px solid var(--gray_400);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  position: relative;
  z-index: 2;
}

.progress-step.active {
  border-color: var(--blue_900);
  background-color: var(--blue_900);
  color: white;
}

.progress-step.complete {
  border-color: var(--blue_900);
  background-color: var(--blue_900);
  color: white;
}

/* Responsive styling */
@media only screen and (max-width: 768px) {
  .popup-content {
    padding: 30px 20px;
    max-width: 90%;
  }
  
  .form-row {
    flex-direction: column;
    gap: 15px;
  }
  
  .popup-title {
    font-size: 26px;
  }
  
  .popup-subtitle {
    font-size: 14px;
    margin-bottom: 20px;
  }
  
  .form-group {
    gap: 5px;
  }
  
  .form-control {
    padding: 12px;
    font-size: 15px;
  }
  
  .form-submit {
    padding: 14px 20px;
  }
}

/* Animation for popup appear/disappear */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(30px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(30px) scale(0.95); }
}

.popup.active .popup-content {
  animation: fadeIn 0.5s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

.popup:not(.active) .popup-content {
  animation: fadeOut 0.3s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

/* Form element focus indicators */
.form-control:focus {
  border-color: var(--gray_600);
  box-shadow: 0 0 0 3px rgba(123, 123, 123, 0.1);
}

/* Optional loading state */
.form-submit.loading {
  position: relative;
  color: transparent;
}

.form-submit.loading::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin-left: -10px;
  margin-top: -10px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 0.8s linear infinite;
}

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

/* Hide scrollbar in popup when not needed */
.popup-content {
  scrollbar-width: thin;
  scrollbar-color: var(--gray_400) transparent;
}

.popup-content::-webkit-scrollbar {
  width: 6px;
}

.popup-content::-webkit-scrollbar-track {
  background: transparent;
}

.popup-content::-webkit-scrollbar-thumb {
  background-color: var(--gray_400);
  border-radius: 6px;
}

/* Ensure text in popup is selectable */
.popup-content {
  user-select: text;
}

/* Floating labels (optional enhancement) */
.form-group.floating {
  position: relative;
}

.form-group.floating label {
  position: absolute;
  left: 15px;
  top: 15px;
  font-size: 16px;
  color: var(--gray_600);
  pointer-events: none;
  transition: all 0.3s ease;
  background: transparent;
}

.form-group.floating.active label,
.form-group.floating input:focus ~ label,
.form-group.floating input:not(:placeholder-shown) ~ label,
.form-group.floating select:focus ~ label,
.form-group.floating textarea:focus ~ label,
.form-group.floating select:not([value=""]):not([value="undefined"]) ~ label {
  top: -10px;
  left: 10px;
  font-size: 12px;
  color: var(--gray_600);
  padding: 0 5px;
  background: white;
}

.form-group.floating input::placeholder,
.form-group.floating textarea::placeholder,
.form-group.floating select::placeholder {
  color: transparent;
}