/* ============================================
   JAC Finance Card - Complete Styling v4.0
   Sidebar card + Modal calculator with red headers
   ============================================ */

/* ========================================
   SIDEBAR FINANCE CARD
   ======================================== */

.jac-finance-card {
  background: var(--jac-white);
  border-radius: 8px;
  box-shadow: 0 1px 3px var(--jac-true-black-a10);
  padding: 24px;
  margin-bottom: 24px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.jac-finance-header {
  margin-bottom: 20px;
}

.jac-finance-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--jac-black);
  margin: 0;
  line-height: 1.2;
}

.jac-price-display {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--jac-border);
}

.jac-price-amount {
  font-size: 36px;
  font-weight: 700;
  color: var(--jac-red);
  line-height: 1.2;
  margin-bottom: 8px;
}

.jac-price-note {
  font-size: 13px;
  color: var(--jac-grey-500);
  margin: 0;
  font-style: italic;
}

.jac-finance-summary {
  margin-bottom: 24px;
}

.jac-finance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--jac-surface-soft);
}

.jac-finance-row:last-child {
  border-bottom: none;
}

.jac-finance-label {
  font-size: 15px;
  color: var(--jac-grey-500);
  font-weight: 400;
}

.jac-finance-value {
  font-size: 16px;
  color: var(--jac-black);
  font-weight: 600;
}

.jac-finance-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

/* COMPONENT PURITY FIX:
   Local .jac-btn override removed (line 87-102 + variants).
   Finance card buttons now rely on canonical .jac-btn from jac-components.css.
   Added finance-specific layout adjustments only.
*/

.jac-finance-buttons .jac-btn {
  width: 100%;
}

/* All button variants (.jac-btn--secondary, .jac-btn-tertiary) now inherit from canonical jac-components.css */

.jac-btn-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.jac-finance-terms {
  font-size: 12px;
  color: var(--jac-grey-400);
  line-height: 1.5;
  margin: 0;
}

/* ========================================
   MODAL CALCULATOR
   ======================================== */

.jac-modal-container {
  max-width: 100%;
}

.jac-modal-wrapper {
  background: var(--jac-white);
  border-radius: var(--radius-lg, 12px);
  overflow: hidden;
  height: 95vh;
  max-height: 95vh;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px var(--jac-true-black-a30);
  position: relative;
}

/* Modal Header - RED BACKGROUND (All Modals) */
.jac-modal-header {
  padding: 28px 36px;
  background: var(--jac-red);
  color: var(--jac-white);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
}

.jac-modal-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--jac-white);
  margin: 0 0 8px 0;
  font-family: 'Inter', sans-serif;
  line-height: 1.2;
}

.jac-modal-subtitle {
  font-size: 17px;
  color: var(--jac-white-a95);
  margin: 0;
  font-family: 'Inter', sans-serif;
}

.jac-modal-body {
  padding: var(--space-40, 2.5rem) var(--space-48, 3rem);
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

.jac-calc-section {
  margin-bottom: 36px;
}

.jac-calc-section:last-child {
  margin-bottom: 0;
}

.jac-calc-section-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--jac-black);
  margin: 0 0 20px 0;
  font-family: 'Inter', sans-serif;
}

/* Grid Layouts */
.jac-calc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.jac-calc-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.jac-calc-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

/* Fields */
.jac-calc-field,
.jac-calc-field-full {
  display: flex;
  flex-direction: column;
}

.jac-calc-field-full {
  margin-bottom: 0;
}

.jac-calc-field label,
.jac-calc-field-full label {
  font-size: 14px;
  font-weight: 500;
  color: var(--jac-grey-700);
  margin-bottom: 8px;
  font-family: 'Inter', sans-serif;
}

/* Display Fields */
.jac-calc-display,
.jac-calc-price-display {
  padding: 14px 18px;
  background: var(--jac-surface-muted);
  border: 2px solid var(--jac-border);
  border-radius: var(--radius-md, 8px);
  font-size: 16px;
  color: var(--jac-black);
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  min-height: 52px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
}

.jac-calc-price-display {
  font-size: 28px;
  font-weight: 700;
  color: var(--jac-red);
  background: var(--jac-white);
  border: 2px solid var(--jac-red);
  min-height: auto;
  padding: 18px 20px;
  box-shadow: 0 2px 8px var(--jac-red-a12);
}

/* Variant dropdown special styling */
#jac-calc-variant-select {
  font-weight: 500;
  color: var(--jac-black);
}

#jac-calc-variant-select option:first-child {
  color: var(--jac-grey-400);
}

#jac-calc-variant-select:invalid {
  color: var(--jac-grey-400);
}

/* Input Fields */
.jac-calc-input {
  padding: 14px 16px;
  border: 2px solid var(--jac-border);
  border-radius: var(--radius-md, 8px);
  font-size: 16px;
  color: var(--jac-black);
  font-weight: 500;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
  width: 100%;
  background: var(--jac-white);
  min-height: 52px;
  box-sizing: border-box;
}

.jac-calc-input:focus {
  outline: none;
  border-color: var(--jac-red);
  box-shadow: 0 0 0 3px var(--jac-red-a10);
}

.jac-calc-input:hover:not(:focus) {
  border-color: var(--jac-grey-400);
}

/* Select dropdowns match input styling */
select.jac-calc-input {
  padding: 13px 16px;
  appearance: none;
  background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='currentColor' d='M6 9L1 4h10z'/%3E%3C/svg%3E\");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

/* Balloon dropdown narrower since values are short */
#jac-calc-balloon {
  max-width: 120px;
}

/* Input Group with Increment/Decrement Buttons */
.jac-calc-input-group {
  display: flex;
  align-items: stretch;
  gap: 0;
  width: 100%;
  min-height: 52px;
}

.jac-calc-input-stepper {
  flex: 1;
  border-radius: 0;
  border-left: none;
  border-right: none;
  text-align: center;
  min-width: 90px;
  font-size: 16px;
  font-weight: 500;
  padding: 14px 8px;
  min-height: 52px;
  box-sizing: border-box;
}

.jac-calc-btn-decrement,
.jac-calc-btn-increment {
  width: 52px;
  height: 52px;
  min-height: 52px;
  background: var(--jac-white);
  border: 2px solid var(--jac-border);
  color: var(--jac-grey-700);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  flex-shrink: 0;
  box-sizing: border-box;
}

.jac-calc-btn-decrement {
  border-radius: var(--radius-md, 8px) 0 0 var(--radius-md, 8px);
}

.jac-calc-btn-increment {
  border-radius: 0 var(--radius-md, 8px) var(--radius-md, 8px) 0;
}

.jac-calc-btn-decrement:hover,
.jac-calc-btn-increment:hover {
  background: var(--jac-red);
  border-color: var(--jac-red);
  color: var(--jac-white);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px var(--jac-red-a20);
}

.jac-calc-btn-decrement:active,
.jac-calc-btn-increment:active {
  background: var(--jac-red-a85);
  border-color: var(--jac-red-a85);
  color: var(--jac-white);
  transform: translateY(0);
  box-shadow: none;
}

.jac-calc-helper {
  font-size: 12px;
  color: var(--jac-grey-400);
  margin-top: 6px;
  font-family: 'Inter', sans-serif;
}

/* Results Breakdown */
.jac-calc-results {
  background: var(--jac-surface-muted);
  padding: 24px;
  border-radius: 8px;
}

.jac-calc-breakdown {
  margin-bottom: 24px;
}

.jac-calc-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: 15px;
  color: var(--jac-grey-700);
  font-family: 'Inter', sans-serif;
}

.jac-calc-breakdown-row span:last-child {
  font-weight: 600;
  color: var(--jac-black);
}

.jac-calc-breakdown-divider {
  border-top: 1px solid var(--jac-border);
  padding-top: 16px;
  margin-top: 6px;
}

.jac-calc-interest {
  color: var(--jac-red) !important;
}

.jac-calc-breakdown-total {
  border-top: 2px solid var(--jac-border-strong);
  padding-top: 16px;
  margin-top: 10px;
  font-size: 16px;
  font-weight: 600;
}

.jac-calc-breakdown-total span:last-child {
  font-size: 18px;
  color: var(--jac-black);
}

/* Monthly Highlight */
.jac-calc-monthly-highlight {
  background: var(--jac-white);
  border: 2px solid var(--jac-red);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
}

.jac-calc-monthly-label {
  font-size: 14px;
  color: var(--jac-grey-500);
  margin-bottom: 8px;
  font-family: 'Inter', sans-serif;
}

.jac-calc-monthly-amount {
  font-size: 42px;
  font-weight: 700;
  color: var(--jac-red);
  margin-bottom: 8px;
  font-family: 'Inter', sans-serif;
  line-height: 1;
}

.jac-calc-monthly-note {
  font-size: 13px;
  color: var(--jac-grey-400);
  font-family: 'Inter', sans-serif;
}

/* Actions */
.jac-calc-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
}

.jac-btn-large {
  padding: 16px 32px;
  font-size: 17px;
  font-weight: 600;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1024px) {
  .jac-calc-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .jac-finance-card {
    padding: 20px;
  }

  .jac-finance-title {
    font-size: 20px;
  }

  .jac-price-amount {
    font-size: 28px;
  }

  /* Canonical .jac-btn handles responsive sizing via component system */

  .jac-modal-wrapper {
    height: 98vh;
    max-height: 98vh;
    border-radius: var(--radius-md, 8px);
  }

  .jac-modal-header {
    padding: 20px;
  }

  .jac-modal-title {
    font-size: 24px;
  }

  .jac-modal-body {
    padding: var(--space-24, 1.5rem) var(--space-20, 1.25rem);
  }

  .jac-calc-grid,
  .jac-calc-grid-3,
  .jac-calc-grid-4 {
    grid-template-columns: 1fr;
  }

  .jac-calc-section-title {
    font-size: 18px;
  }

  .jac-calc-price-display {
    font-size: 24px;
  }

  .jac-calc-monthly-amount {
    font-size: 32px;
  }

  .jac-calc-actions {
    flex-direction: column;
  }

  .jac-btn-large {
    width: 100%;
  }

  /* Close button mobile optimization */
  .glightbox-clean .gclose {
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
  }

  .glightbox-clean .gclose svg {
    width: 20px;
    height: 20px;
  }
}

@media (max-width: 480px) {
  .jac-price-amount {
    font-size: 24px;
  }
  
  .jac-calc-monthly-amount {
    font-size: 28px;
  }
}

/* Touch Targets */
@media (hover: none) and (pointer: coarse) {
  /* Canonical .jac-btn already handles touch target sizing (min-height: 48px) */

  .jac-calc-input {
    min-height: 52px;
  }
}

/* ========================================
   GLightbox Modal Overrides
   ======================================== */

.gslide-media {
  box-shadow: none !important;
}

.gslide-inline .ginner-container {
  padding: 0 !important;
}

.jac-modal-container .gslide-description {
  display: none !important;
}

/* Ensure modal close button is visible on red background */
.glightbox-clean .gclose {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: var(--jac-white);
  border: 2px solid var(--jac-border);
  border-radius: 50%;
  box-shadow: 0 4px 12px var(--jac-true-black-a20);
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 1;
}

.glightbox-clean .gclose:hover {
  background: var(--jac-red);
  border-color: var(--jac-red);
  box-shadow: 0 6px 20px var(--jac-red-a30);
  transform: scale(1.08);
}

.glightbox-clean .gclose svg,
.glightbox-clean .gclose .gclose-icon {
  width: 20px;
  height: 20px;
  stroke: var(--jac-black);
  stroke-width: 2.5px;
  transition: stroke 0.2s ease;
}

.glightbox-clean .gclose:hover svg,
.glightbox-clean .gclose:hover .gclose-icon {
  stroke: var(--jac-white);
}

/* Variant dropdown selected state */
#jac-calc-variant-select {
  border: 2px solid var(--jac-border);
  transition: border-color 0.2s ease;
}

#jac-calc-variant-select:focus {
  border-color: var(--jac-red);
  outline: none;
}

/* Fix Fluent Form submit button in modals */
.jac-modal-body .ff-btn-submit,
.jac-modal-body .ff_btn_style,
.jac-modal-body button[type="submit"] {
  background: var(--jac-red) !important;
  border-color: var(--jac-red) !important;
  color: var(--jac-white) !important;
  font-weight: 600 !important;
  padding: 14px 28px !important;
  border-radius: 6px !important;
  transition: all 0.2s ease !important;
}

.jac-modal-body .ff-btn-submit:hover,
.jac-modal-body .ff_btn_style:hover,
.jac-modal-body button[type="submit"]:hover {
  background: var(--jac-red-a85) !important;
  border-color: var(--jac-red-a85) !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 8px var(--jac-red-a20) !important;
}

/* ============================================
   GLIGHTBOX DOUBLE SCROLL FIX
   Problem: GLightbox adds inline width styles that create nested scroll
   Solution: Aggressive override of ALL GLightbox containers
   ============================================ */

/* Force GLightbox to NOT add scrollbars on outer containers */
.glightbox-container {
  overflow: hidden !important;
}

.gslide {
  overflow: visible !important;
}

.gslide-inline {
  overflow: visible !important;
  width: 100% !important;
  max-width: none !important;
}

.gslide-media {
  overflow: visible !important;
  width: 100% !important;
}

/* The actual modal content container */
#jac-modal-finance-calc {
  overflow: visible !important;
  width: 100% !important;
  max-width: 820px !important;
  margin: 0 auto !important;
}

/* Ensure ONLY the modal body scrolls */
#jac-modal-finance-calc .jac-modal-body {
  overflow-y: auto !important;
  overflow-x: hidden !important;
}
