/* =========================================================
   FLY TECH – Mobile Finance CSS (iOS + Android)
   File: style_mobile_finance.css
   ระดับความสำคัญ: Responsive Mobile-First
   Brand Color: #00A987 (Teal Green)
   
   ปัญหาที่แก้ไข:
   ✓ Layout ไม่สมบูรณ์บนมือถือ
   ✓ ฟอร์มลม็อฟเวอร์ไม่ทำงาน
   ✓ ปุ่มและ input ขนาดไม่เหมาะสม
   ✓ ราคาและผลลัพธ์ซ้ำซ้อน
   ✓ Safe area ไม่สนับสนุน
   ========================================================= */

/* ========== 1. Reset Finance Card สำหรับมือถือ ========== */
@media (max-width: 980px) {
  
  /* ยกเลิก padding บนเดสก์ */
  .ft-calc-card {
    padding: 16px;
    margin: 0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
  }

  /* ========== 2. Layout หลักให้เป็น Stack (Vertical) ========== */
  .ft-layout {
    display: flex !important;
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
  }

  /* โค้งกรรม pane ให้เต็มความกว้าง */
  .ft-pane-visual,
  .ft-pane-controls,
  .ft-pane-form {
    width: 100% !important;
    max-width: none !important;
  }

  /* ========== 3. รูปโดรนให้มีขนาดเหมาะสมบนมือถือ ========== */
  .ft-product-preview {
    width: 100%;
    max-width: 280px;
    height: auto;
    margin: 0 auto 16px;
    border-radius: 14px;
    overflow: hidden;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
  }

  .ft-product-preview img {
    width: 100%;
    height: auto;
    max-width: 260px;
    object-fit: contain;
  }

  /* ========== 4. ราคาการ์ด ========== */
  .ft-price-tag {
    background: linear-gradient(135deg, rgba(0, 169, 135, 0.08), rgba(0, 169, 135, 0.04));
    border: 1px solid rgba(0, 169, 135, 0.2);
    padding: 14px 16px;
    border-radius: 14px;
    text-align: center;
    margin-bottom: 12px;
  }

  .ft-price-tag label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
  }

  .ft-price-display {
    font-size: 1.8rem;
    font-weight: 900;
    color: #00a987;
    line-height: 1;
    letter-spacing: -0.5px;
  }

  /* ========== 5. แก้ไข Side Summary ========== */
  .ft-side-summary {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 0;
  }

  /* ========== 6. ฟอร์มกรอกข้อมูล - 1 คอลัมน์บนมือถือ ========== */
  .ft-form-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px;
    width: 100%;
  }

  .ft-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
  }

  .ft-field.full-width {
    grid-column: span 1 !important;
  }

  /* ========== 7. Label ฟอร์ม ========== */
  .ft-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: block;
  }

  /* ========== 8. Input & Select ให้มี Touch-Friendly Size ========== */
  .ft-input,
  .ft-select select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    background: #fff;
    
    font-size: 16px; /* สำคัญ: หลีกเลี่ยงการเลือกบน iOS */
    font-weight: 500;
    color: #1e293b;
    
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    
    /* Touch-friendly height (min 44px) */
    min-height: 44px;
    
    /* Safe area */
    padding-right: 40px; /* เผื่อลูกศร */
  }

  .ft-input:focus,
  .ft-select select:focus {
    border-color: #00a987;
    box-shadow: 0 0 0 3px rgba(0, 169, 135, 0.1);
    outline: none;
  }

  .ft-select {
    position: relative;
  }

  .ft-select::after {
    content: "";
    position: absolute;
    right: 14px;
    top: 50%;
    width: 8px;
    height: 8px;
    transform: translateY(-50%) rotate(45deg);
    border-right: 2px solid #00a987;
    border-bottom: 2px solid #00a987;
    pointer-events: none;
    z-index: 1;
  }

  /* ========== 9. Input ที่ Disable (Interest) ========== */
  .ft-input.bg-gray,
  .ft-input[disabled] {
    background: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
    opacity: 0.9;
  }

  /* ========== 10. ปุ่มคำนวณ ========== */
  .ft-calc-actions {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }

  .ft-btn,
  #btnCalc {
    width: 100%;
    padding: 14px 16px;
    background: linear-gradient(135deg, #00a987, #008c73);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    min-height: 44px;
    text-align: center;
    
    /* ป้องกัน auto-zoom ใน iOS */
    font-size: 16px;
  }

  .ft-btn:active,
  #btnCalc:active {
    transform: translateY(1px);
  }

  .ft-btn:not(:disabled):hover,
  #btnCalc:not(:disabled):hover {
    box-shadow: 0 8px 20px rgba(0, 169, 135, 0.3);
  }

  .ft-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
  }

  /* ========== 11. Consult Link ========== */
  .ft-consult-link {
    margin-top: 16px;
    text-align: center;
    font-size: 0.85rem;
    color: #475569;
  }

  .ft-consult-link a {
    color: #00a987;
    font-weight: 700;
    text-decoration: none;
    transition: color 0.2s ease;
  }

  .ft-consult-link a:active {
    color: #006e5a;
  }

  /* ========== 12. ผลลัพธ์ - Result Box ========== */
  .ft-result-old-style {
    width: 100%;
    border: 2px solid #00a987;
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 169, 135, 0.1);
    margin-top: 20px;
  }

  .ft-result-header {
    background: linear-gradient(135deg, #00a987, #008c73);
    color: #fff;
    padding: 12px 14px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.3px;
  }

  .ft-result-rows {
    padding: 0;
  }

  .ft-res-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
    gap: 8px;
  }

  .ft-res-row:last-child {
    border-bottom: none;
  }

  .ft-res-row span {
    color: #64748b;
    font-weight: 500;
  }

  .ft-res-row strong {
    color: #1e293b;
    font-weight: 700;
    text-align: right;
  }

  .ft-res-row.highlight {
    background: rgba(0, 169, 135, 0.08);
  }

  .ft-res-row.highlight strong {
    color: #00a987;
    font-size: 1.2rem;
    font-weight: 800;
  }

  /* ========== 13. Spacer ========== */
  .ft-result-spacer {
    display: none;
  }

  /* ========== 14. Pane Controls ========== */
  .ft-pane-controls {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  /* ========== 15. Breadcrumb ========== */
  .breadcrumb {
    font-size: 0.85rem !important;
    margin-bottom: 20px !important;
    overflow-x: auto !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: baseline !important;
    gap: 3px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
  }

  .breadcrumb a {
    display: inline !important;
    color: #00a987 !important;
    text-decoration: none !important;
    font-weight: 600 !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    font-size: 0.85rem !important;
    white-space: nowrap !important;
  }

  .breadcrumb span {
    display: inline !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
    font-size: 0.85rem !important;
    color: #64748b !important;
    font-weight: 400 !important;
    white-space: nowrap !important;
  }

  /* ========== 16. Safe Area Support สำหรับ iOS ========== */
  @supports (padding: env(safe-area-inset-bottom)) {
    .ft-calc-card {
      padding-left: env(safe-area-inset-left, 16px);
      padding-right: env(safe-area-inset-right, 16px);
    }

    .ft-consult-link,
    .ft-calc-actions {
      padding-left: env(safe-area-inset-left, 0);
      padding-right: env(safe-area-inset-right, 0);
    }

    body.with-notch {
      padding-top: calc(68px + env(safe-area-inset-top));
    }
  }

  /* ========== 17. Header fixes ========== */
  .site-header {
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
  }

  /* ========== 18. Section Padding ========== */
  .section {
    padding: 24px 0;
  }

  .container {
    padding: 0 16px;
    max-width: 100%;
  }

  /* ========== 19. Calc Card Head ========== */
  .ft-calc-head {
    margin-bottom: 20px !important;
    text-align: center !important;
  }

  .ft-calc-title {
    font-size: 1.3rem !important;
    font-weight: 800 !important;
    color: #1e293b !important;
    margin: 0 0 6px !important;
    line-height: 1.3 !important;
    letter-spacing: -0.3px !important;
  }

  .ft-calc-subtitle {
    font-size: 0.85rem !important;
    color: #64748b !important;
    margin: 0 !important;
    font-weight: 400 !important;
    line-height: 1.4 !important;
  }

  /* ========== 20. CTA Band ========== */
  .cta-band {
    flex-direction: column;
    gap: 24px;
  }

  .cta-title {
    font-size: 1.2rem;
    font-weight: 800;
  }

  .cta-subtitle {
    font-size: 0.9rem;
  }

  .cta-actions {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    padding: 14px 16px;
    font-size: 0.95rem;
    min-height: 44px;
  }

  .cta-right {
    width: 100%;
  }

  .line-card {
    flex-direction: column;
    text-align: center;
  }



  /* ========== 21. Prevent iOS Zoom on Input Focus ========== */
  @supports (-webkit-touch-callout: none) {
    /* iOS only */
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="tel"],
    input[type="password"],
    select,
    textarea {
      font-size: 16px;
      padding-top: 12px;
      padding-bottom: 12px;
    }

    /* ลบ blue highlight ใน iOS */
    input:not([type="checkbox"]):not([type="radio"]),
    select,
    textarea {
      -webkit-user-select: text;
      -webkit-appearance: none;
    }
  }

  /* ========== 22. Viewport & Scrolling ========== */
  body {
    overflow-x: hidden;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    user-select: none;
  }

  input,
  button,
  select,
  textarea {
    -webkit-user-select: text;
    user-select: text;
  }

  a {
    -webkit-user-select: none;
    user-select: none;
  }

  /* ========== 23. Prevent Flickering ========== */
  * {
    -webkit-tap-highlight-color: rgba(0, 169, 135, 0.1);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* ========== 24. Footer ========== */
  .site-footer {
    padding: 24px 16px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }

  /* ========== 25. Loading state ========== */
  body.is-loading {
    overflow: hidden;
  }

}

/* ========== Medium devices (iPad, etc.) ========== */
@media (max-width: 768px) {
  .ft-form-grid {
    grid-template-columns: 1fr !important;
  }

  .ft-calc-card {
    padding: 20px;
  }

  .ft-layout {
    gap: 24px;
  }
}

/* ========== Large mobile (Landscape) ========== */
@media (max-width: 980px) and (orientation: landscape) {
  body {
    padding-top: 64px;
  }

  .ft-calc-card {
    padding: 12px 16px;
  }

  .ft-layout {
    flex-direction: row;
    gap: 16px;
  }

  .ft-pane-visual {
    flex: 0 0 35%;
    display: flex;
    flex-direction: column;
  }

  .ft-product-preview {
    max-width: 100%;
    height: auto;
    min-height: 150px;
  }

  .ft-pane-controls {
    flex: 1;
  }

  .ft-form-grid {
    grid-template-columns: 1fr !important;
  }

  .ft-calc-title {
    font-size: 1.1rem;
  }

  .ft-section {
    padding: 16px 0;
  }
}

/* ========== Accessibility Improvements ========== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

