/* =========================================================
   FLY TECH – Mobile Product Detail CSS (iOS + Android)
   File: style_mobile_product.css
   ระดับความสำคัญ: Responsive Mobile-First for Product Pages
   Brand Color: #00A987 (Teal Green)
   
   ปัญหาที่แก้ไข:
   ✓ Product detail layout 2-column ทำลาย
   ✓ Thumbnail gallery ไม่ทำงาน
   ✓ Price box ไม่อ่านได้
   ✓ Spec grid ซ้อนเสมอ
   ✓ Action buttons ตกล้ว
   ✓ Safe area ไม่สนับสนุน
   ✓ Spec table ไม่ทำงาน
   ✓ Bundle grid ยุ่ม
   ========================================================= */

/* ========== 1. Product Detail Card - Main Layout ========== */
@media (max-width: 980px) {

  /* ========== 2. Reset & Main Layout ========== */
  
  /* Product detail stack vertically */
  .product-detail {
    display: flex !important;
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
    width: 100%;
  }

  .product-detail-media,
  .product-detail-info {
    width: 100%;
  }

  /* ========== 3. Main Product Image ========== */
  .product-detail-main {
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    max-width: 100%;
    height: auto;
  }

  .product-detail-main img {
    width: 100%;
    height: auto;
    display: block;
    min-height: 250px;
    object-fit: contain;
  }

  /* ========== 4. Thumbnail Gallery - Horizontal Scroll ========== */
  .product-detail-thumbs {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding: 0 0 8px 0;
  }

  .thumb {
    flex: 0 0 auto;
    border: 2px solid #e2e8f0;
    background: #fff;
    border-radius: 12px;
    padding: 4px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-height: 60px;
    width: 60px;
    scroll-snap-align: center;
    -webkit-user-select: none;
    user-select: none;
  }

  .thumb:hover {
    border-color: #00a987;
  }

  .thumb.is-active {
    border-color: #00a987;
    box-shadow: 0 4px 12px rgba(0, 169, 135, 0.2);
    background: #f0fdf9;
  }

  .thumb img {
    width: 52px;
    height: 52px;
    object-fit: contain;
  }

  /* Disclaimer */
  .text-muted {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 12px;
    line-height: 1.4;
  }

  /* ========== 5. Product Badge ========== */
  .product-badge {
    display: inline-block;
    background: rgba(0, 169, 135, 0.12);
    color: #00a987;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
  }

  /* ========== 6. Product Title ========== */
  .product-detail-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-top: 12px;
    margin-bottom: 8px;
    color: #1e293b;
    line-height: 1.2;
  }

  .product-detail-subtitle {
    color: #64748b;
    margin-top: 8px;
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.5;
  }

  /* ========== 7. Price Box ========== */
  .price-box {
    margin-top: 16px;
    border: 2px solid #00a987;
    border-radius: 14px;
    padding: 12px 14px;
    background: rgba(0, 169, 135, 0.05);
    width: 100%;
  }

  .price-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed rgba(0, 169, 135, 0.2);
  }

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

  .price-label {
    color: #64748b;
    font-weight: 600;
    font-size: 0.85rem;
    flex: 1;
  }

  .price-value {
    font-weight: 800;
    color: #00a987;
    font-size: 1rem;
    text-align: right;
    white-space: nowrap;
  }

  /* ========== 8. Action Buttons ========== */
  .product-detail-actions {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  .product-detail-actions a {
    flex: 1;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    cursor: pointer;
    text-align: center;
  }

  .btn-primary {
    background: linear-gradient(135deg, #00a987, #008c73);
    color: #fff;
    border: none;
  }

  .btn-primary:active {
    transform: translateY(1px);
  }

  .btn-yun {
    background: #f1f5f9;
    color: #00a987;
    border: 2px solid #00a987;
  }

  .btn-yun:active {
    background: #e2e8f0;
  }

  .btn-calc {
    background: #fff;
    color: #00a987;
    border: 2px solid #00a987;
  }

  .btn-calc:active {
    background: #f8fafc;
  }

  /* ========== 9. Spec Grid ========== */
  .spec-grid {
    margin-top: 16px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
  }

  .spec-item {
    border: 1px solid rgba(0, 169, 135, 0.2);
    border-radius: 12px;
    padding: 12px;
    background: rgba(0, 169, 135, 0.08);
    width: 100%;
  }

  .spec-k {
    font-size: 0.75rem;
    color: #00a987;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: block;
  }

  .spec-v {
    margin-top: 6px;
    font-weight: 700;
    color: #1e293b;
    font-size: 0.9rem;
  }

  /* ========== 10. Detail Sections ========== */
  .detail-sections {
    margin-top: 24px;
    display: grid;
    gap: 16px;
    width: 100%;
  }

  .detail-card {
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 16px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    width: 100%;
  }

  .detail-card h2 {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 12px;
    color: #1e293b;
  }

  /* ========== 11. Spec Sheet Table ========== */
  .specsheet-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
  }

  .specsheet-head h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
  }

  .btn-mini {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 700;
    background: #00a987;
    color: #fff;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* ========== 12. Spec Table - Mobile Friendly ========== */
  .spec-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
  }

  .spec-table tr {
    border-bottom: 1px solid #e2e8f0;
  }

  .spec-table tr:last-child {
    border-bottom: none;
  }

  .spec-table td {
    padding: 10px 8px;
    text-align: left;
  }

  .spec-key {
    font-weight: 700;
    color: #1e293b;
    width: 40%;
    padding-right: 12px;
  }

  .spec-val {
    color: #64748b;
    word-break: break-word;
  }

  .spec-section {
    background: rgba(0, 169, 135, 0.08);
  }

  .spec-section td {
    font-weight: 800;
    color: #00a987;
    padding: 12px 8px;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.3px;
  }

  /* ========== 13. Bundle Grid ========== */
  .bundle-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
  }

  .bundle-item {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    background: #fff;
  }

  .bundle-item h3 {
    font-size: 0.95rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: #1e293b;
  }

  .bundle-item p {
    font-size: 0.85rem;
    color: #64748b;
    margin: 0;
    line-height: 1.5;
  }

  .bundle-price {
    font-size: 1.1rem;
    font-weight: 800;
    color: #00a987;
    margin-top: 8px;
  }

  /* ========== 14. FAQ ========== */
  .faq details {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 8px;
    background: #fff;
  }

  .faq summary {
    cursor: pointer;
    font-weight: 700;
    color: #1e293b;
    font-size: 0.95rem;
    user-select: none;
  }

  .faq details[open] summary {
    color: #00a987;
    margin-bottom: 8px;
  }

  .faq details > *:not(summary) {
    padding-left: 0;
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.6;
  }

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

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

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

  .cta-actions {
    flex-direction: column;
    gap: 12px;
  }

  .cta-actions a {
    width: 100%;
    min-height: 44px;
    font-size: 0.95rem;
  }

  .cta-right {
    width: 100%;
  }

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

  .line-card-text {
    order: 2;
  }



  
  /* ========== 17. Breadcrumb ========== */
  .breadcrumb {
    font-size: 0.85rem !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    padding: 0 !important;
    margin-bottom: 16px !important;
    display: inline-flex !important;
    align-items: baseline !important;
    gap: 3px !important;
    line-height: 1 !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;
  }

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

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

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

  /* ========== 19. Safe Area Support ========== */
  @supports (padding: env(safe-area-inset-bottom)) {
    .container {
      padding-left: max(16px, env(safe-area-inset-left));
      padding-right: max(16px, env(safe-area-inset-right));
    }

    .product-detail-actions {
      padding-left: env(safe-area-inset-left, 0);
      padding-right: env(safe-area-inset-right, 0);
    }
  }

  /* ========== 20. Prevent iOS Auto-zoom ========== */
  button, a {
    font-size: 16px;
  }

  /* ========== 21. Top Button ========== */
  .ft-top {
    position: fixed;
    bottom: 80px;
    right: 16px;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #00a987, #008c73);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.75rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 169, 135, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .ft-top.is-visible {
    opacity: 1;
    visibility: visible;
  }

  /* ========== 22. Prevent Text Selection ========== */
  body {
    -webkit-user-select: none;
    user-select: none;
    overflow-x: hidden;
  }

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

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

  /* ========== 24. Tablet Optimizations (768px - 979px) ========== */
  @media (max-width: 768px) {
    .product-detail {
      gap: 24px;
    }

    .product-detail-main img {
      min-height: 300px;
    }

    .product-detail-title {
      font-size: 1.4rem;
    }

    .detail-card {
      padding: 20px;
    }

    .bundle-grid {
      grid-template-columns: 1fr;
    }
  }

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

    .product-detail {
      flex-direction: row;
      gap: 16px;
    }

    .product-detail-media {
      flex: 0 0 40%;
      max-height: 60vh;
      overflow-y: auto;
    }

    .product-detail-info {
      flex: 1;
      max-height: 60vh;
      overflow-y: auto;
    }

    .product-detail-main img {
      min-height: auto;
      max-height: 300px;
    }

    .product-detail-title {
      font-size: 1.2rem;
    }

    .spec-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  /* ========== 26. Reduced Motion ========== */
  @media (prefers-reduced-motion: reduce) {
    * {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
    }
  }

  
/* ========== Small screens Extra Optimization ========== */
@media (max-width: 480px) {
  .product-detail-title {
    font-size: 1.3rem;
  }

  .price-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .price-value {
    text-align: left;
    font-size: 1.15rem;
  }

  .product-detail-actions {
    gap: 8px;
  }

  .bundle-grid {
    grid-template-columns: 1fr;
  }

  .spec-table {
    font-size: 0.8rem;
  }
}
}