/* ========================================
   CALCULATOR WIDGET STYLES
   ======================================== */

/* Main Container */
.calculator-container {
  display: flex;
  padding: 32px;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  border-radius: 12px;
  background: #f7cd46;
  position: relative;
  font-family:
    "Public Sans",
    -apple-system,
    Roboto,
    Helvetica,
    sans-serif;
  max-width: 800px;
  margin: 0 auto;
  overflow: visible;
  box-sizing: border-box;
  word-wrap: break-word;
}

/* No Background State */
.calculator-container.no-background {
  background: transparent !important;
  border: none !important;
}

/* Ensure no background override works in Elementor */
.elementor-widget-mystic-calculator .calculator-container.no-background {
  background: transparent !important;
  border: none !important;
}

/* Additional specificity for Elementor editor */
.elementor-editor-active .calculator-container.no-background {
  background: transparent !important;
  border: none !important;
}

/* Auto-Flex Container */
.calculator-container.auto-flex {
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  flex: 1;
  padding: clamp(12px, 3vw, 20px);
  gap: clamp(6px, 1.5vw, 12px);
  box-sizing: border-box;
  justify-content: space-between;
  min-height: 100%;
}

/* Auto-flex overrides for child elements */
.calculator-container.auto-flex .calculator-header {
  padding: 0;
  flex-shrink: 0;
}

.calculator-container.auto-flex .calculator-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: clamp(6px, 1.5vw, 12px);
  min-height: 0;
}

.calculator-container.auto-flex .form-controls-wrapper {
  padding: 0;
}

.calculator-container.auto-flex .result-card {
  margin: 0;
}

.calculator-container.auto-flex .cta-buttons-grid {
  padding: 0;
  flex-shrink: 0;
}



/* Header Section */
.calculator-header {
  display: flex;
  padding: 0 16px;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  align-self: stretch;
  text-align: center;
}

.calculator-title {
  color: #514209;
  font-family:
    "Public Sans",
    -apple-system,
    Roboto,
    Helvetica,
    sans-serif;
  font-size: 22px;
  font-style: normal;
  font-weight: 600;
  line-height: 120%;
  letter-spacing: -0.44px;
  margin: 0;
}

.calculator-subtitle {
  align-self: stretch;
  color: #77610d;
  text-align: center;
  font-family:
    "Public Sans",
    -apple-system,
    Roboto,
    Helvetica,
    sans-serif;
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  line-height: 160%;
  margin: 0;
}

/* Form Section */
.calculator-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  align-self: stretch;
}

.form-controls-wrapper {
  display: flex;
  padding: 0 16px;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  align-self: stretch;
}

.form-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  align-self: stretch;
}

.form-label {
  align-self: stretch;
  color: #514209;
  font-family:
    "Public Sans",
    -apple-system,
    Roboto,
    Helvetica,
    sans-serif;
  font-size: 16px;
  font-style: normal;
  font-weight: 600;
  line-height: 160%;
  margin: 0;
}

.form-select-wrapper {
  position: relative;
  display: flex;
  align-self: stretch;
  z-index: 10;
}

.form-select {
  display: flex;
  min-height: 52px;
  padding: 12px 44px 12px 20px;
  justify-content: space-between;
  align-items: center;
  align-self: stretch;
  border-radius: 8px;
  border: 1px solid #fae48d;
  background: #fae48d;
  color: #514209;
  font-family:
    "Public Sans",
    -apple-system,
    Roboto,
    Helvetica,
    sans-serif;
  font-size: 16px;
  font-style: normal;
  font-weight: 400;
  line-height: 150%;
  letter-spacing: 0.16px;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}

.form-select:focus {
  outline: 2px solid #b0540d;
  outline-offset: 2px;
}

.select-arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  width: 24px;
  height: 24px;
  z-index: 2;
}

/* Result Card */
.result-card {
  display: flex;
  padding: 24px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  align-self: stretch;
  border-radius: 8px;
  border: 1px solid #fae48d;
  background: #fae48d;
  margin: 0 16px;
  text-align: center;
}

.result-title {
  color: #514209;
  font-family:
    "Public Sans",
    -apple-system,
    Roboto,
    Helvetica,
    sans-serif;
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
  line-height: 120%;
  letter-spacing: 0.24px;
  text-transform: uppercase;
  opacity: 0.7;
  margin: 0;
}

.result-amount {
  color: #514209;
  font-family:
    "Public Sans",
    -apple-system,
    Roboto,
    Helvetica,
    sans-serif;
  font-size: 28px;
  font-style: normal;
  font-weight: 500;
  line-height: 120%;
  letter-spacing: -0.84px;
  margin: 0;
  transition: opacity 0.15s ease;
}

.result-disclaimer {
  align-self: stretch;
  color: #514209;
  text-align: center;
  font-family:
    "Public Sans",
    -apple-system,
    Roboto,
    Helvetica,
    sans-serif;
  font-size: 14px;
  font-style: normal;
  font-weight: 400;
  line-height: 150%;
  margin: 0;
}

/* CTA Buttons Grid */
.cta-buttons-grid {
  display: flex;
  padding: 0 16px 32px 16px;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  align-self: stretch;
}

.cta-button {
  display: flex;
  min-height: 52px;
  padding: 12px 20px;
  justify-content: center;
  align-items: center;
  gap: 8px;
  align-self: stretch;
  border-radius: 8px;
  background: #fefbec;
  text-decoration: none;
  transition:
    background-color 0.2s ease,
    transform 0.1s ease;
  box-sizing: border-box;

  color: #b0540d;
  font-family:
    "Public Sans",
    -apple-system,
    Roboto,
    Helvetica,
    sans-serif;
  font-size: 16px;
  font-style: normal;
  font-weight: 600;
  line-height: 150%;
}

.cta-button:hover {
  background: #f5f0d8;
  transform: translateY(-1px);
  text-decoration: none;
  color: #b0540d;
}

.cta-button:focus {
  outline: 2px solid #b0540d;
  outline-offset: 2px;
}

.cta-button:active {
  transform: translateY(0);
}

.cta-button span {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========================================
   RESPONSIVE STYLES
   ======================================== */

/* Mobile Styles */
@media (max-width: 767px) {
  .form-select {
    font-size: 16px; /* Prevents zoom on iOS */
    -webkit-appearance: menulist;
    -moz-appearance: menulist;
    appearance: menulist;
    position: relative;
    z-index: 1000;
  }

  .form-select:focus {
    z-index: 1001;
  }

  .form-select-wrapper {
    position: relative;
    z-index: 100;
    isolation: isolate;
  }

  .calculator-container {
    overflow: visible;
    position: relative;
    z-index: 1;
    isolation: isolate;
  }

  .form-controls-wrapper {
    position: relative;
    z-index: 10;
    overflow: visible;
  }

  .calculator-form {
    overflow: visible;
    position: relative;
    z-index: 5;
  }

  .result-card {
    position: relative;
    z-index: 1;
  }

  /* Ensure dropdown options appear above other elements */
  .form-select option {
    background: #fae48d;
    color: #514209;
  }

  /* Adjust arrow position for mobile */
  .select-arrow {
    z-index: 2;
    pointer-events: none;
  }


}

/* Desktop Styles */
@media (min-width: 768px) {
  .calculator-container {
    padding-top: 32px;
  }

  .calculator-header {
    padding: 0 24px;
  }

  .calculator-title {
    font-size: 24px;
    letter-spacing: -0.48px;
    color: #3b3007;
  }

  .calculator-subtitle {
    color: #6a560b;
  }

  .form-controls-wrapper {
    display: flex;
    padding: 0 24px;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
    align-self: stretch;
  }

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

  .result-card {
    margin: 0 24px;
  }

  .result-amount {
    color: #3b3007;
    font-size: 40px;
    letter-spacing: -1.2px;
  }

  .cta-buttons-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 12px;
    padding: 0 24px 24px 24px;
    align-self: stretch;
  }

  .cta-button {
    height: 48px;
    flex: 1 0 0;
    align-self: auto;
  }

  /* Auto-flex desktop overrides */
  .calculator-container.auto-flex {
    padding: clamp(16px, 4vw, 32px);
  }

  .calculator-container.auto-flex .calculator-header {
    padding: 0;
  }

  .calculator-container.auto-flex .form-controls-wrapper {
    padding: 0;
  }

  .calculator-container.auto-flex .result-card {
    margin: 0;
  }

  .calculator-container.auto-flex .cta-buttons-grid {
    padding: 0;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .cta-button {
    transition: none;
  }

  .cta-button:hover {
    transform: none;
  }

  .cta-button:active {
    transform: none;
  }

  .result-amount {
    transition: none;
  }
}

/* ========================================
   ACCESSIBILITY ENHANCEMENTS
   ======================================== */

.form-select:focus-visible {
  outline: 2px solid #b0540d;
  outline-offset: 2px;
}

.cta-button:focus-visible {
  outline: 2px solid #b0540d;
  outline-offset: 2px;
}

/* ========================================
   HIGH CONTRAST MODE SUPPORT
   ======================================== */

@media (prefers-contrast: high) {
  .form-select {
    border-width: 2px;
  }

  .cta-button {
    border: 2px solid #b0540d;
  }

  .result-card {
    border-width: 2px;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .calculator-container {
    background: white !important;
    box-shadow: none !important;
  }

  .cta-button {
    background: white !important;
    border: 1px solid #000 !important;
    color: #000 !important;
  }

  .cta-button svg {
    display: none;
  }
}

/* ========================================
   ELEMENTOR EDITOR SPECIFIC FIXES
   ======================================== */

.elementor-editor-active .calculator-container {
  min-height: 400px;
}

.elementor-editor-active .form-select {
  pointer-events: none;
}

.elementor-editor-active .cta-button {
  pointer-events: none;
}



/* ========================================
   LOADING STATES
   ======================================== */

.calculator-container.loading .result-amount::after {
  content: "...";
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0%,
  20% {
    color: rgba(81, 66, 9, 0.4);
    text-shadow:
      0.25em 0 0 rgba(81, 66, 9, 0.4),
      0.5em 0 0 rgba(81, 66, 9, 0.4);
  }
  40% {
    color: #514209;
    text-shadow:
      0.25em 0 0 rgba(81, 66, 9, 0.4),
      0.5em 0 0 rgba(81, 66, 9, 0.4);
  }
  60% {
    text-shadow:
      0.25em 0 0 #514209,
      0.5em 0 0 rgba(81, 66, 9, 0.4);
  }
  80%,
  100% {
    text-shadow:
      0.25em 0 0 #514209,
      0.5em 0 0 #514209;
  }
}

/* ========================================
   RTL SUPPORT
   ======================================== */

[dir="rtl"] .form-select {
  padding: 12px 20px 12px 44px;
}

[dir="rtl"] .select-arrow {
  right: auto;
  left: 12px;
}

[dir="rtl"] .cta-button {
  flex-direction: row-reverse;
}



/* ========================================
   RESPONSIVE IMPROVEMENTS
   ======================================== */

@media (max-width: 480px) {
  .calculator-container {
    padding: 16px;
    gap: 16px;
  }
  
  .calculator-title {
    font-size: 18px !important;
    line-height: 1.3 !important;
  }
  
  .calculator-subtitle {
    font-size: 14px !important;
  }
  
  .form-controls-wrapper {
    gap: 12px;
  }
  
  .cta-buttons-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .result-amount {
    font-size: 24px !important;
  }
}

/* ========================================
   ACCESSIBILITY IMPROVEMENTS
   ======================================== */

.calculator-container:focus-within {
  outline: 2px solid #b0540d;
  outline-offset: 2px;
}

.form-select:focus {
  outline: 2px solid #b0540d;
  outline-offset: 2px;
}

.cta-button:focus {
  outline: 2px solid #b0540d;
  outline-offset: 2px;
}

/* ========================================
   ERROR STATES
   ======================================== */

.calculator-container.error {
  border: 2px solid #dc3545;
  background: #fff5f5;
}

.calculator-container.error .result-amount {
  color: #dc3545;
}

.calculator-container.error .result-amount::after {
  content: " (Error loading rates)";
  font-size: 14px;
  font-weight: normal;
}

/* ========================================
   RATE SOURCE LINKS
   ======================================== */

.rate-source-links {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid rgba(176, 84, 13, 0.2);
}

.rate-links-title {
  font-size: 14px;
  font-weight: 600;
  color: #514209;
  margin-bottom: 8px;
  text-align: center;
}

.rate-links-container {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.rate-source-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: rgba(254, 251, 236, 0.8);
  border: 1px solid rgba(176, 84, 13, 0.3);
  border-radius: 6px;
  color: #B0540D;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.rate-source-link:hover {
  background: rgba(254, 251, 236, 1);
  border-color: rgba(176, 84, 13, 0.5);
  color: #8A420A;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(176, 84, 13, 0.1);
}

.rate-source-link svg {
  flex-shrink: 0;
}

/* Mobile responsive for rate source links */
@media (max-width: 480px) {
  .rate-links-container {
    flex-direction: column;
    align-items: center;
  }

  .rate-source-link {
    width: 100%;
    max-width: 280px;
    justify-content: center;
  }
}
