/* ========================================
   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;
}

/* No Background State */
.calculator-container.no-background {
  background: transparent;
  border: 2px dashed #ddd;
}

/* 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;
}

/* Background Toggle Button */
.background-toggle-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
  z-index: 50;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.background-toggle-btn:hover {
  background: rgba(255, 255, 255, 1);
  transform: scale(1.1);
}

.background-toggle-btn:focus {
  outline: 2px solid #b0540d;
  outline-offset: 2px;
}

/* 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;
  }

  /* Ensure proper stacking context */
  .background-toggle-btn {
    z-index: 50;
  }
}

/* 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;
  }

  .background-toggle-btn {
    display: none;
  }

  .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;
}

.elementor-editor-active .background-toggle-btn {
  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;
}

[dir="rtl"] .background-toggle-btn {
  right: auto;
  left: 8px;
}
