/* ============================================================
   DesignNext Installment Modal - PERFECT RESPONSIVE v3.0
   Fully fixed version – NO LEFT/RIGHT SCROLLING
============================================================ */

:root {
  --primary: #2d9a6d;
  --primary-light: #3db87e;
  --primary-dark: #1f6b4d;
  --text: #333333;
  --text-muted: #666666;
  --border: #e0e0e0;
  --lighter: #f0f4f8;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* ============================================================
   MOBILE FIRST
============================================================ */

.installment-modal {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 99999;
  backdrop-filter: blur(4px);
  animation: fadeInOverlay 0.3s ease;
  padding: 12px;
  overflow-y: auto;
}

.installment-content {
  background: #ffffff;
  border-radius: 14px;
  width: 100%;
  max-width: 100%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  animation: slideUpContent 0.4s ease forwards;
  font-family: 'Segoe UI', 'Helvetica Neue', system-ui, -apple-system, sans-serif;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.installment-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #ffffff;
  padding: 14px 16px;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.installment-header .close {
  font-size: 24px;
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

.installment-header .close:hover {
  opacity: 1;
}

/* ============================================================
   BODY
============================================================ */

/*** FIX: NO HORIZONTAL SCROLL ***/
.installment-popup-body {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px;
  padding: 14px;
  overflow-y: auto;
  overflow-x: hidden !important;
  flex: 1;
  min-height: 0;
}

/* ---------- Left Section ---------- */
.installment-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.installment-left img {
  width: 100%;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  object-fit: cover;
  aspect-ratio: 1;
}

.installment-left-info h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.installment-left-info p {
  margin: 0;
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}

/* ---------- Right Section ---------- */
.installment-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.installment-right h3 {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  padding-bottom: 6px;
  border-bottom: 2px solid var(--lighter);
}

/* ---------- Table-like rows ---------- */
.plan-row {
  display: table;
  width: 100%;
  table-layout: fixed;
  font-size: 12px;
  padding: 4px 0;
}

.plan-row-label {
  display: table-cell;
  color: var(--text-muted);
  font-weight: 500;
  text-align: left;
  padding-right: 8px;
}

.plan-row-value {
  display: table-cell;
  color: var(--text);
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

/* ---------- Dropdown ---------- */
.installment-right label {
  margin-top: 6px;
  margin-bottom: 4px;
  font-weight: 600;
  color: var(--text);
  font-size: 12px;
  display: block;
}

.installment-term {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%232d9a6d' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
  padding-right: 28px;
}

.installment-term:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(45, 154, 109, 0.1);
}

/* ---------- EMI Box ---------- */
.emi-result {
  margin-top: 6px;
  background: linear-gradient(135deg, rgba(45, 154, 109, 0.08) 0%, rgba(61, 184, 126, 0.08) 100%);
  border: 2px solid var(--primary-light);
  border-left: 4px solid var(--primary);
  padding: 10px;
  border-radius: 8px;
  text-align: center;
  animation: slideInEMI 0.3s ease forwards;
  display: none;
}

.emi-result.show {
  display: block;
}

.emi-result p {
  margin: 0 0 3px;
  color: var(--text-muted);
  font-size: 10px;
}

.emi-result h4 {
  margin: 0;
  color: var(--primary);
  font-weight: 700;
  font-size: 18px;
}

.emi-result small {
  display: block;
  color: var(--text-muted);
  font-size: 10px;
  margin-top: 2px;
}

/* ---------- Pay Button ---------- */
.pay-downpayment {
  width: 100%;
  margin-top: 8px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #ffffff;
  border: none;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(45, 154, 109, 0.3);
}

.pay-downpayment:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  transform: translateY(-1px);
}

.pay-downpayment:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================
   ANIMATIONS
============================================================ */

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideInEMI {
  from { transform: translateX(-15px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   TABLET & ABOVE
============================================================ */

@media (min-width: 768px) {
  .installment-content {
    max-width: 750px;
  }

  /** FIXED 2-COLUMN RESPONSIVE LAYOUT **/
  .installment-popup-body {
    flex-direction: row !important;
    gap: 20px;
    padding: 20px;
  }

  .installment-left {
    flex: 0 0 40%;
  }

  .installment-right {
    flex: 1;
  }
}

/* ============================================================
   LARGE DESKTOP
============================================================ */

@media (min-width: 1024px) {
  .installment-content {
    max-width: 900px;
  }

  .installment-popup-body {
    gap: 24px;
    padding: 24px;
  }

  .installment-left {
    flex: 0 0 42%;
  }

  .installment-right {
    flex: 1;
  }
}

/* ---------- PRINT ---------- */
@media print {
  .installment-modal { display: none; }
}
