/* ==========================================================================
   Module: Quick Installment Widget (Stitch Edition)
   Style: Cinematic Luxury / Glassmorphism
   ========================================================================== */
.installment-quick {
  padding: 8rem 0;
  background-color: var(--color-black);
  position: relative;
  overflow: hidden;
}

/* Hiệu ứng nền quét laser nhẹ */
.installment-quick::before {
  content: '';
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(200, 0, 26, 0.05), transparent);
  animation: scanline 10s linear infinite;
  pointer-events: none;
}

@keyframes scanline {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.stitch-luxury-glass {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 40px;
  padding: 3.5rem;
  box-shadow: 0 40px 100px rgba(0,0,0,0.5);
  position: relative;
  z-index: 1;
}

/* Form Styles */
.iq-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 800;
  color: #ff3333; /* Đỏ sáng hơn trên nền tối */
  text-shadow: 0 0 10px rgba(255, 51, 51, 0.2);
  letter-spacing: 2px;
  margin-bottom: 0.75rem;
}

.iq-select-wrap {
  position: relative;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  padding: 0 1.5rem;
  transition: all 0.3s;
}

.iq-select-wrap:focus-within {
  border-color: var(--color-primary);
  background: rgba(200, 0, 26, 0.05);
}

.iq-select {
  width: 100%;
  height: 56px;
  background: transparent;
  border: none;
  color: #fff;
  font-weight: 600;
  appearance: none;
  cursor: pointer;
  outline: none;
}

/* Range Input Stylized */
.iq-range-container {
  padding: 1rem 0;
}

.iq-range-input {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  appearance: none;
  outline: none;
}

.iq-range-input::-webkit-slider-thumb {
  appearance: none;
  width: 24px;
  height: 24px;
  background: var(--color-primary);
  border: 4px solid #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 15px rgba(200,0,26,0.5);
}

.iq-range-display {
  font-family: 'Bai Jamjuree', sans-serif;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
}

/* Cinematic Car Visual */
.iq-live-visual {
  transition: all 0.5s ease;
  border: 1px solid rgba(255,255,255,0.05);
}

.iq-live-visual:hover {
  border-color: rgba(200, 0, 26, 0.2);
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

.iq-live-visual img.updating {
  opacity: 0;
  transform: translateX(20px) scale(0.95);
}

/* Result Card */
.iq-result-card {
  background: #111;
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 24px;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
}

.iq-result-header {
  font-size: 0.65rem;
  font-weight: 800;
  color: #555;
  letter-spacing: 2px;
  margin-bottom: 2rem;
  text-align: center;
}

.iq-res-label {
  display: block;
  font-size: 0.8rem;
  color: #888;
  margin-bottom: 0.5rem;
}

.iq-res-value {
  font-size: 2.5rem;
  font-weight: 900;
  font-family: 'Bai Jamjuree', sans-serif;
  line-height: 1;
}

.iq-res-value span {
  font-size: 1.2rem;
  opacity: 0.5;
  margin-left: 4px;
}

.color-gold { color: var(--color-gold); text-shadow: 0 0 20px rgba(184,146,42,0.3); }
.color-red { color: var(--color-primary); text-shadow: 0 0 20px rgba(200,0,26,0.3); }

.iq-interest-tag {
  font-size: 0.7rem;
  color: #444;
  margin-top: 0.5rem;
  font-style: italic;
}


.iq-number-wrap {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.9); /* Trắng sứ cực kỳ nổi bật */
  border: 1px solid #ffffff;
  border-radius: 12px;
  padding: 4px 14px;
  transition: all 0.3s;
  width: fit-content;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.iq-number-wrap:focus-within {
  background: #ffffff;
  box-shadow: 0 15px 40px rgba(200, 0, 26, 0.3);
  transform: scale(1.05); /* Phóng to nhẹ khi click */
}

.iq-number-input {
  width: 55px;
  background: transparent !important;
  border: none !important;
  color: #000000 !important; /* Chữ đen sâu cực dễ đọc */
  text-align: center;
  font-weight: 900;
  font-size: 1.3rem;
  padding: 8px 0;
  outline: none;
  font-family: 'Bai Jamjuree', sans-serif;
  appearance: textfield;
}

.iq-unit-pct {
  font-weight: 950;
  color: #C8001A; /* Đỏ Mitsubishi tạo điểm nhấn */
  font-size: 1.15rem;
  margin-left: 4px;
  font-family: 'Bai Jamjuree', sans-serif;
  pointer-events: none;
}

/* Ẩn mũi tên input number */
.iq-number-input::-webkit-outer-spin-button,
.iq-number-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Modal Styles */
.iq-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); padding: 15px;
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
#iq-modal-lead-gate {
  z-index: 10001 !important; /* Luôn trên cùng để nhập tin */
}
#iq-modal-lead-gate .iq-modal__content {
  max-width: 450px;
  border: 1px solid rgba(255,255,255,0.1);
}

.iq-modal.active {
  opacity: 1; pointer-events: auto;
}

.iq-modal__content {
  background: #fff; border-radius: 24px; width: 100%; max-width: 900px;
  max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
  color: #1a1a1a;
  box-shadow: 0 50px 100px rgba(0,0,0,0.5);
  transform: translateY(20px);
  transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.iq-modal.active .iq-modal__content {
  transform: translateY(0);
}

.iq-modal__header {
  padding: 1.5rem 2rem; border-bottom: 1px solid #eee;
  display: flex; justify-content: space-between; align-items: center;
  background: #fcfcfc;
}

.iq-modal__header h3 {
  margin: 0; font-weight: 850; font-size: 1.25rem; color: #000;
  font-family: 'Bai Jamjuree', sans-serif;
}

.iq-modal__close {
  background: #f1f1f1; border: none; font-size: 1.5rem; cursor: pointer; color: #666;
  width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}

.iq-modal__close:hover {
  background: #e2e2e2; color: #000;
}

.iq-modal__body {
  padding: 0 2.5rem 2.5rem 2.5rem; overflow: auto; flex: 1; /* Phải là overflow: auto để sticky header hoạt động */
}

.iq-modal__footer {
  padding: 1.5rem 2rem; border-top: 1px solid #eee;
  display: flex; justify-content: flex-end; gap: 1rem; background: #f9f9f9;
}

.iq-schedule-summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1.5rem; margin-bottom: 2.5rem; padding: 2rem; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 16px;
  margin-top: 2.5rem; /* Bù đắp cho padding-top bị xóa ở iq-modal__body */
}

.iq-summary-item span {
  display: block; font-size: 0.7rem; color: #64748b; margin-bottom: 6px; text-transform: uppercase; font-weight: 700; letter-spacing: 1px;
}

.iq-summary-item strong {
  font-size: 1.1rem; color: #1e293b; font-weight: 850; font-family: 'Bai Jamjuree', sans-serif;
}

.iq-table-wrap {
  border: 1px solid #f1f5f9; border-radius: 12px; overflow: visible !important; /* Phải là visible để sticky header hoạt động */
}

.iq-table {
  width: 100%; border-collapse: collapse; font-size: 0.85rem;
}

.iq-table th {
  position: sticky;
  top: -1px; /* Một chút offset để che hoàn toàn border khi cuộn */
  z-index: 10;
  background: var(--color-dark-1);
  padding: 16px 12px;
  text-align: left;
  font-weight: 800;
  border-bottom: 2px solid var(--color-dark-3);
  color: var(--color-text-secondary);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1); 
}

.iq-table td {
  padding: 14px 12px; border-bottom: 1px solid #f1f5f9; color: #1e293b;
}

.iq-table tr:nth-child(even) { background: #fafafa; }
.iq-table tr:hover { background: #f1f5f9; }

/* Print & Export Header */
.iq-export-header {
  display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid #C8001A; padding-bottom: 1rem;
}

/* Print optimization */
@media print {
  body * { visibility: hidden; }
  #iq-schedule-print-area, #iq-schedule-print-area * { visibility: visible; }
  #iq-schedule-print-area { position: absolute; left: 0; top: 0; width: 100%; padding: 0 !important; }
  .iq-export-header { display: flex !important; }
  .iq-modal { background: none; position: relative; }
  .iq-modal__content { box-shadow: none; border: none; width: 100%; max-width: 100%; }
}

/* Responsive */
@media (max-width: 1024px) {
  .stitch-luxury-glass {
    padding: 3rem 2rem;
  }
  .iq-layout-grid {
    grid-template-columns: 1fr !important;
    gap: 3rem !important;
  }
}

@media (max-width: 768px) {
  /* ==========================================================================
     MOBILE RESPONSIVE UPGRADES (SCOPE ISOLATION)
     Chỉ áp dụng cho màn hình <= 768px. Tuyệt đối không ảnh hưởng PC/Tablet.
     TỐI ƯU KHÔNG GIAN (NÉN PADDING/MARGIN/GAP)
     ========================================================================== */
  
  /* 1. Kích thước Layout khung ngoài - Giảm tối đa margin/padding */
  .installment-quick { 
    padding: 1rem 0; 
  }
  .stitch-luxury-glass {
    padding: 1.25rem 0.75rem !important;
    gap: 1rem !important;
    border-radius: 20px !important;
  }

  /* 2. Style Header văn bản & Badge */
  .section__header h2,
  .iq-mobile-layout .section__title {
    font-size: 1.3rem !important;
    text-align: center;
    letter-spacing: 0;
  }
  .section__header p,
  .iq-mobile-layout .section__header p { 
    text-align: center; 
    font-size: 0.8rem;
    margin-top: 5px !important;
  }
  .x-hero__badge {
    margin: 0 auto 0.5rem auto !important;
    padding: 4px 10px !important;
    font-size: 9px !important;
  }
  .section__header { 
    margin-bottom: 1.25rem !important; 
  }

  /* 3. Form fields - Nén các ô nhập liệu cho sát nhau (2 CỘT 1 DÒNG TRÊN MOBILE) */
  .iq-form-common > div:nth-child(1),
  .iq-form-common > div:nth-child(3) {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.75rem !important;
    margin-bottom: 0.75rem !important;
  }
  
  .iq-form-common > div:nth-child(2) {
    margin-bottom: 1rem !important;
  }
  .iq-label {
    font-size: 0.6rem !important;
    letter-spacing: 0.5px !important;
    margin-bottom: 0.4rem !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Box Vốn tự có */
  .iq-form-common > div:nth-child(2) > div:nth-child(1) {
    flex-wrap: nowrap !important;
    gap: 0.5rem;
    align-items: center !important;
    margin-bottom: 0.25rem !important;
  }
  .iq-number-wrap { 
    width: auto !important;
    min-width: 60px;
    padding: 2px 8px;
  }
  .iq-unit-pct { font-size: 0.7rem; }
  .iq-number-input {
    font-size: 1.15rem;
    padding: 4px 0;
  }

  /* Thu nhỏ height của các thẻ select/input để đỡ tốn diện tích dọc */
  .iq-select {
    height: 48px;
    font-size: 0.9rem;
  }
  .iq-select-wrap {
    padding: 0 1rem;
  }

  /* 4. Thẻ Kết Quả Dự Toán */
  .installment-quick__side-result {
    display: none !important;
  }
  .iq-mobile-only {
    display: block !important;
  }
  .iq-result-card {
    padding: 1.25rem !important;
    border-radius: 12px !important;
  }
  .iq-res-value { 
    font-size: 1.6rem !important; 
  }
  .iq-result-header {
    margin-bottom: 1rem !important;
    font-size: 0.7rem;
  }
  .iq-actions { 
    margin-top: 1.25rem !important; 
  }
  .iq-actions > div:last-child { 
    grid-template-columns: 1fr !important;
    gap: 8px !important; 
    margin-top: 8px !important;
  }
  #iq-show-schedule {
    height: 46px !important;
    font-size: 0.8rem;
  }

  /* -------------------------------------
     MODAL BẢNG QUY ĐỔI CHI TIẾT (NÉN NHỎ THÊM)
     ------------------------------------- */
  .iq-modal { 
    padding: 8px !important; 
  }
  .iq-modal__content {
    border-radius: 12px !important;
    max-height: 98vh;
  }
  .iq-modal__header { 
    padding: 1rem !important; 
  }
  .iq-modal__header h3 {
    font-size: 1rem !important;
    white-space: normal;
  }
  .iq-modal__body { 
    padding: 0.75rem !important; 
  }

  /* Header thông tin Đại lý giảm cao */
  .iq-export-header {
    flex-direction: column !important;
    gap: 1rem !important;
    align-items: center !important;
    padding-bottom: 0.75rem !important;
    margin-bottom: 1.25rem !important;
  }
  .iq-export-header > div:nth-child(1) {
    flex-direction: column !important;
    text-align: center !important;
    gap: 0.5rem !important;
  }
  .iq-export-header > div:nth-child(1) img { 
    height: 35px !important; 
  }
  .iq-export-header > div:nth-child(2) { 
    text-align: center !important; 
  }
  .iq-export-header > div:nth-child(2) div { 
    justify-content: center !important; 
  }

  /* Phần tổng quan dòng xe nén khung */
  .iq-schedule-summary {
    display: flex !important;
    flex-direction: column !important;
    padding: 1rem !important;
    gap: 1rem !important;
    border-radius: 12px !important;
    margin-bottom: 1.25rem !important;
  }
  .iq-summary-visual {
    border-right: none !important;
    border-bottom: 1px solid #eee !important;
    padding-right: 0 !important;
    padding-bottom: 0.75rem !important;
  }
  .iq-summary-visual img {
    min-height: auto !important;
    max-height: 120px;
  }
  .iq-summary-details > div {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  /* Bảng lịch thanh toán cuộn ngang */
  /* Đẩy cuộn ngang lên modal body để sticky header hoạt động */
  .iq-table-wrap {
    overflow: visible !important;
    border-radius: 8px !important;
  }
  .iq-modal__body {
     padding: 0 1rem 1.25rem 1rem !important; /* Xóa padding-top để sticky header sát viền */
     overflow: auto !important;
  }
  /* Thêm khoảng cách cho phần tóm tắt phía trên bảng */
  .iq-schedule-summary {
     margin-top: 1.25rem !important;
  }
  .iq-table th, .iq-table td {
    padding: 8px 6px !important;
    font-size: 11px !important;
  }
  .iq-table td:first-child {
    font-size: 10px !important;
    font-weight: 500 !important;
  }
  .iq-table { 
    min-width: 550px; /* Ép bảng đủ rộng để kích hoạt cuộn X tại modal-body */
  }

  /* Footer dưới cùng modal chứa Nút Action */
  .iq-modal__footer {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    padding: 0.75rem !important;
    gap: 0.5rem !important;
  }
  #iq-btn-print { 
    grid-column: span 2; 
    display: none !important; 
  } 
  #iq-btn-jpg-modal, #iq-btn-pdf-modal { 
    grid-column: span 1; 
    padding: 0.75rem 0; 
    font-size: 0.75rem !important;
  }
  .iq-modal__footer [data-modal-open="modal-booking"] { 
    grid-column: span 2; 
    padding: 0.75rem 0 !important;
  }
  
  /* Cột phụ chú + Sale Rep trong Modal */
  .iq-export-footer > div {
    grid-template-columns: 1fr !important;
    gap: 1.25rem !important;
  }
  
  .iq-export-footer {
     margin-top: 1.25rem !important;
     padding-top: 1.25rem !important;
  }
  .iq-modal__content--mobile-result {
    background: var(--color-black) !important;
    border: 1px solid var(--color-dark-3) !important;
  }
  
  .iq-modal__content--mobile-result .iq-modal__header {
    background: var(--color-dark-1) !important;
    border-bottom: 1px solid var(--color-dark-3) !important;
  }
  
  .iq-modal__content--mobile-result .iq-modal__header h3 {
    color: var(--color-text-primary) !important;
  }
  
  /* Đảm bảo nội dung bên trong result card (khi được clone) cũng dùng biến */
  .iq-modal__content--mobile-result .iq-result-card {
    border: none !important;
    background: transparent !important;
    color: var(--color-text-primary) !important;
  }

  .iq-modal__content--mobile-result .iq-res-value {
    color: var(--color-text-primary) !important;
  }

  .iq-modal__content--mobile-result .color-gold { color: var(--color-gold) !important; }
  .iq-modal__content--mobile-result .color-red { color: var(--color-primary) !important; }
  .iq-modal__content--mobile-result .iq-res-label { color: var(--color-text-secondary) !important; }
}
.iq-mobile-only {
  display: none;
}

/* ==========================================================================
   DESKTOP RECONSTRUCTION FOR EXPORT (MOBILE STABILIZATION)
   Ensures that exported files look like PC/Desktop regardless of viewport.
   ========================================================================== */
/* Fixed Reconstruction for Export Header */
.iq-desktop-force .iq-export-header {
  display: flex !important;
  flex-direction: row !important;
  justify-content: space-between !important;
  width: 100% !important;
  gap: 2.5rem !important;
  text-align: left !important;
}
.iq-desktop-force .iq-export-header > div:nth-child(2) {
  text-align: right !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-end !important;
  flex: 1;
}
.iq-desktop-force .iq-export-header > div:nth-child(1) {
  display: flex !important;
  flex-direction: row !important;
  text-align: left !important;
  gap: 1.5rem !important;
  flex: 1;
}
.iq-desktop-force .iq-export-header > div:nth-child(1) img { 
  height: 60px !important; 
}
.iq-desktop-force .iq-export-header > div:nth-child(2) div { 
  justify-content: flex-end !important; 
}

.iq-desktop-force .iq-schedule-summary {
  display: grid !important;
  grid-template-columns: 1.2fr 2fr !important;
  flex-direction: row !important;
  gap: 2.5rem !important;
  padding: 2.5rem !important;
  border-radius: 20px !important;
}
.iq-desktop-force .iq-summary-visual {
  border-right: 1px solid #f1f1f1 !important;
  border-bottom: none !important;
  padding-right: 2.5rem !important;
  padding-bottom: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
}
.iq-desktop-force #iq-schedule-vehicle-img {
  width: auto !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: 200px !important;
  display: block !important;
  margin: 0 auto !important;
  object-fit: contain !important;
}
.iq-desktop-force .iq-summary-details > div {
  grid-template-columns: 1fr 1fr !important;
  gap: 1.2rem !important;
}
.iq-desktop-force .iq-table th, 
.iq-desktop-force .iq-table td {
  padding: 12px 15px !important;
  font-size: 13px !important;
}
.iq-desktop-force .iq-table {
  min-width: 100% !important;
}
.iq-desktop-force .iq-export-footer > div {
  grid-template-columns: 1.5fr 1fr 1fr !important;
  gap: 2rem !important;
}
.iq-desktop-force .iq-export-footer {
  margin-top: 3rem !important;
  padding-top: 2rem !important;
}
