/**
 * All of the CSS for your public-facing functionality should be
 * included in this file.
 */

/* ================================
   Product Finder Frontend Styles
   ================================ */

.wp-pf-finder {
  background: var(--white-color, #ffffff);
  border-radius: 8px;
  padding: 30px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-width: 500px;
  margin: 40px auto;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
}

.wp-pf-fields-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 25px;
}

.wp-pf-field {
  display: flex;
  flex-direction: column;
}

.wp-pf-field-label {
  font-weight: 700;
  font-size: 15px;
  color: #3a2a6a;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.wp-pf-field-main-label {
  font-weight: 700;
  font-size: 15px;
  color: #3a2a6a;
  flex: 1;
}

.wp-pf-field-sub-label {
  font-weight: 400;
  font-size: 12px;
  color: var(--text_color-color, #58595b);
  margin-top: 2px;
  font-style: italic;
}

.wp-pf-field-count {
  font-weight: 400;
  font-size: 14px;
  color: var(--text_color-color, #58595b);
  margin-left: 10px;
  flex-shrink: 0;
}

.wp-pf-select-wrapper {
  position: relative;
}

/* Custom Dropdown Styling */
.wp-pf-custom-select {
  position: relative;
  width: 100%;
  cursor: pointer;
}

.wp-pf-custom-select[data-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.wp-pf-select-display {
  width: 100%;
  background: var(--white-color, #ffffff);
  border: none;
  border-bottom: 2px solid #ddd;
  font-size: 14px;
  color: var(--text_color-color, #58595b);
  padding: 12px 30px 10px 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  transition: all 0.3s ease;
  min-height: 20px;
}

.wp-pf-custom-select:hover .wp-pf-select-display {
  border-bottom-color: #7b68ee;
}

.wp-pf-custom-select.active .wp-pf-select-display {
  border-bottom-color: #7b68ee;
}

.wp-pf-custom-select.active {
  z-index: 10000 !important;
  position: relative;
}

.wp-pf-select-text {
  flex: 1;
  color: #888;
  font-weight: 400;
  font-style: italic;
}

.wp-pf-select-text.placeholder {
  color: #888;
  font-style: italic;
  font-weight: 400;
}

.wp-pf-select-text.selected {
  color: var(--text_color-color, #58595b);
  font-weight: 500;
  font-style: normal;
}

.wp-pf-select-text small {
  font-size: 11px;
  color: #888;
  font-weight: 400;
  font-style: italic;
  line-height: 1.2;
  display: block;
  margin-top: 2px;
}

.wp-pf-select-arrow {
  color: var(--text_color-color, #58595b);
  font-size: 12px;
  transition: transform 0.3s ease;
  margin-left: 10px;
}

.wp-pf-custom-select.active .wp-pf-select-arrow {
  transform: rotate(180deg);
}

/* Dropdown Menu */
.wp-pf-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--white-color, #ffffff);
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999 !important;
  max-height: 200px;
  overflow-y: auto;
}

.wp-pf-option {
  padding: 12px 15px;
  color: var(--text_color-color, #58595b);
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-bottom: 1px solid #f0f0f0;
}

.wp-pf-option:last-child {
  border-bottom: none;
}

.wp-pf-option:hover {
  background-color: #f8f9fa;
}

.wp-pf-option.selected {
  background-color: #7b68ee;
  color: var(--white-color, #ffffff);
}

.wp-pf-option:first-child {
  color: #888;
  font-style: italic;
}

/* Ensure dropdown appears above all other elements */
.wp-pf-field {
  position: relative;
  z-index: 1;
}

.wp-pf-field:has(.wp-pf-custom-select.active),
.wp-pf-field .wp-pf-custom-select.active {
  z-index: 10001 !important;
}

/* Additional z-index fixes for common conflicting elements */
.wp-pf-select-dropdown {
  z-index: 10002 !important;
  position: absolute !important;
}

/* Ensure submit button doesn't interfere */
.wp-pf-submit-container {
  position: relative;
  z-index: 1;
}

/* Ensure results info doesn't interfere */
.wp-pf-results-info {
  position: relative;
  z-index: 1;
}

.wp-pf-select {
  width: 100%;
  background: var(--white-color, #ffffff);
  border: none;
  border-bottom: 2px solid #ddd;
  font-size: 14px;
  color: var(--text_color-color, #58595b) !important;
  padding: 12px 0 10px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg fill='%23333' height='16' viewBox='0 0 24 24' width='16' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.wp-pf-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-image: none;
  color: #999 !important;
}

.wp-pf-select:focus {
  outline: none;
  border-bottom-color: #7b68ee;
}

/* Option styling for better visibility */
.wp-pf-select option {
  color: var(--text_color-color, #58595b) !important;
  background: #ffffff !important;
  padding: 8px 12px;
}

.wp-pf-select option:first-child {
  color: #888 !important;
  font-style: italic;
}

.wp-pf-select option:checked,
.wp-pf-select option:hover {
  background: #f0f0f5 !important;
  color: var(--text_color-color, #58595b) !important;
}

/* Ensure selected value is visible */
.wp-pf-select:not([value=""]) {
  color: var(--text_color-color, #58595b) !important;
  font-weight: 500;
}

/* Loading Spinner */
.wp-pf-loading-spinner {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #ddd;
  border-radius: 50%;
  border-top-color: #7b68ee;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Submit Section */
.wp-pf-submit-container {
  margin-top: 20px;
  text-align: center;
}

.wp-pf-submit {
  background-color: #4b2ca0;
  color: var(--white-color, #ffffff);
  border: none;
  font-weight: 700;
  font-size: 16px;
  border-radius: 8px;
  padding: 16px 32px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 0 #39217e;
  min-width: 200px;
  position: relative;
}

.wp-pf-submit:hover:not(:disabled) {
  background-color: #5e3ac4;
  box-shadow: 0 4px 0 #4523a3;
  transform: translateY(-1px);
}

.wp-pf-submit:disabled {
  background-color: var(--light_background-color, #f9f8f6);
  box-shadow: 0 4px 0 #aaa;
  cursor: not-allowed;
  transform: none;
  opacity: 0.6;
}

.wp-pf-submit-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Results Info */
.wp-pf-results-info {
  margin-top: 15px;
  text-align: center;
}

.wp-pf-product-count {
  font-size: 14px;
  color: var(--text_color-color, #58595b);
  font-style: italic;
}

/* Special styling for no products message */
.wp-pf-product-count.no-products {
  color: var(--error_back-color, #e60000);
  font-weight: 500;
}

/* No Configuration Message */
.wp-pf-no-config {
  text-align: center;
  padding: 40px 20px;
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin: 20px 0;
}

.wp-pf-no-config p {
  margin: 0;
  color: var(--text_color-color, #58595b);
  font-size: 16px;
}

/* Responsive Design */
@media (max-width: 600px) {
  .wp-pf-finder {
    max-width: 100%;
    padding: 20px;
    margin: 20px auto;
  }

  .wp-pf-submit {
    width: 100%;
    min-width: auto;
  }

  .wp-pf-field-label {
    font-size: 14px;
  }

  .wp-pf-select {
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

/* Error States */
.wp-pf-field.error .wp-pf-select {
  border-bottom-color: var(--error_back-color, #e60000);
}

.wp-pf-field.error .wp-pf-field-label {
  color: var(--error_back-color, #e60000);
}

/* Focus States for Accessibility */
.wp-pf-select:focus {
  box-shadow: 0 0 0 2px rgba(123, 104, 238, 0.3);
}

.wp-pf-submit:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(75, 44, 160, 0.3);
}

/* Animation for smooth transitions */
.wp-pf-field {
  transition: opacity 0.3s ease, transform 0.2s ease;
}

.wp-pf-field.loading {
  opacity: 0.7;
}

.wp-pf-field:hover {
  transform: translateY(-1px);
}

/* Enhanced Loading States */
.wp-pf-select:disabled {
  background-color: #f9f9f9;
  color: #999 !important;
}

/* Force text visibility for all browsers - High specificity */
.wp-pf-finder .wp-pf-field .wp-pf-select-wrapper .wp-pf-select,
.wp-pf-finder .wp-pf-select,
.wp-pf-select,
.wp-pf-select:valid,
.wp-pf-select:invalid,
select.wp-pf-select {
  color: var(--text_color-color, #58595b) !important;
  -webkit-text-fill-color: var(--text_color-color, #58595b) !important;
  text-shadow: none !important;
}

/* Ensure selected options are visible */
.wp-pf-finder .wp-pf-select option,
.wp-pf-select option {
  color: var(--text_color-color, #58595b) !important;
  background-color: #ffffff !important;
  -webkit-text-fill-color: var(--text_color-color, #58595b) !important;
}

/* Placeholder styling */
.wp-pf-finder .wp-pf-select option:first-child,
.wp-pf-select option:first-child {
  color: #888 !important;
  -webkit-text-fill-color: #888 !important;
}

/* When option is selected, make sure it's dark */
.wp-pf-finder .wp-pf-select:not([value=""]),
.wp-pf-select:not([value=""]) {
  color: var(--text_color-color, #58595b) !important;
  -webkit-text-fill-color: var(--text_color-color, #58595b) !important;
  font-weight: 500 !important;
}

/* Safari specific fixes */
@supports (-webkit-appearance: none) {
  .wp-pf-select {
    -webkit-text-fill-color: var(--text_color-color, #58595b) !important;
    color: var(--text_color-color, #58595b) !important;
  }

  .wp-pf-select option {
    -webkit-text-fill-color: var(--text_color-color, #58595b) !important;
    color: var(--text_color-color, #58595b) !important;
  }
}

/* Firefox specific fixes */
@-moz-document url-prefix() {
  .wp-pf-select {
    color: var(--text_color-color, #58595b) !important;
    text-shadow: none !important;
  }

  .wp-pf-select option {
    color: var(--text_color-color, #58595b) !important;
  }
}

/* Chrome/Webkit specific */
@media screen and (-webkit-min-device-pixel-ratio:0) {
  .wp-pf-select {
    color: var(--text_color-color, #58595b) !important;
    -webkit-text-fill-color: var(--text_color-color, #58595b) !important;
  }
}

/* Success Animation */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.wp-pf-field {
  animation: fadeInUp 0.3s ease-out;
}

/* Pulse animation for submit button when enabled */
@keyframes pulse {
  0% {
    box-shadow: 0 4px 0 #39217e, 0 0 0 0 rgba(75, 44, 160, 0.7);
  }
  70% {
    box-shadow: 0 4px 0 #39217e, 0 0 0 10px rgba(75, 44, 160, 0);
  }
  100% {
    box-shadow: 0 4px 0 #39217e, 0 0 0 0 rgba(75, 44, 160, 0);
  }
}

.wp-pf-submit:not(:disabled):hover {
  animation: pulse 1.5s infinite;
}

/* Better visual feedback */
.wp-pf-select:focus + .wp-pf-loading-spinner {
  display: none !important;
}

/* Improved accessibility */
.wp-pf-finder *:focus {
  outline: 2px solid #7b68ee;
  outline-offset: 2px;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .wp-pf-finder {
    background: #2c2c2c;
    color: var(--white-color, #ffffff);
  }

  .wp-pf-select {
    background: #2c2c2c;
    color: var(--white-color, #ffffff);
    border-bottom-color: #555;
  }

  .wp-pf-field-label {
    color: #b19cd9;
  }

  .wp-pf-select:disabled {
    background-color: #1a1a1a;
    color: var(--text_color-color, #58595b);
  }
}

/* Notification System */
.wp-pf-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  max-width: 400px;
  animation: slideInRight 0.3s ease-out;
}

.wp-pf-notification-content {
  background: var(--error_back-color, #e60000);
  color: white;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.wp-pf-notification-text {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
}

.wp-pf-notification-close {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.wp-pf-notification-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.wp-pf-notification.hiding {
  animation: slideOutRight 0.3s ease-out forwards;
}

/* CRITICAL: Force select text visibility with maximum specificity */
div.wp-pf-finder div.wp-pf-field div.wp-pf-select-wrapper select.wp-pf-select.wp-pf-select-visible,
div.wp-pf-finder select.wp-pf-select.wp-pf-select-visible,
select.wp-pf-select.wp-pf-select-visible {
  color: var(--text_color-color, #58595b) !important;
  -webkit-text-fill-color: var(--text_color-color, #58595b) !important;
  -moz-text-fill-color: var(--text_color-color, #58595b) !important;
  text-shadow: none !important;
  opacity: 1 !important;
}

/* Force inline style override */
.wp-pf-select[style*="color"] {
  color: var(--text_color-color, #58595b) !important;
}

/* Additional browser-specific overrides */
.wp-pf-select::-webkit-input-placeholder {
  color: #888 !important;
}

.wp-pf-select::-moz-placeholder {
  color: #888 !important;
}

.wp-pf-select:-ms-input-placeholder {
  color: #888 !important;
}

.wp-pf-select::placeholder {
  color: #888 !important;
}


@media (min-width: 601px) {
  div#wp-pf-finder {
    max-width: 75%;
  }
}

@media (max-width: 962px) and (min-width: 782px) {
  div#wp-pf-finder {
    max-width: 95%;
  }
}