/* ==========================================================================
   Bổ sung responsive cho giao diện html-raw (nạp sau home.css / style.css).
   Không sửa CSS gốc — mọi chỉnh sửa cho màn hình nhỏ nằm ở file này.
   ========================================================================== */

/* Cột grid được phép co nhỏ hơn nội dung (tránh tràn ngang do chữ/bảng dài) */
.split > *,
.layout > *,
.about > *,
.cta > *,
.pd > *,
.feature > *,
.lk-grid > *,
.ct-grid > *,
.pr-wrap > *,
.gallery__thumbs > * {
  min-width: 0
}

.std {
  width: 100%
}

.std th,
.std td {
  overflow-wrap: anywhere
}

.gallery__thumbs img {
  width: 100%
}

/* Công cụ tra cứu (trang chủ): fieldset/input mặc định không co nhỏ hơn nội dung */
.lk-form fieldset {
  min-width: 0
}

.row3 {
  grid-template-columns: repeat(3, minmax(0, 1fr))
}

.fld input,
.fld select {
  width: 100%;
  min-width: 0
}

/* Header trang con: nút tìm kiếm thu thành icon như trang chủ */
@media (max-width:1440px) {
  .s-btn {
    min-width: 0;
    width: 44px;
    padding: 0;
    justify-content: center
  }

  .s-btn span,
  .s-btn kbd {
    display: none
  }
}

/* Lưới ngành (trang Sản phẩm) & dải công nghệ (trang Dịch vụ) chưa có điểm ngắt trong html-raw */
@media (max-width:980px) {
  .inds {
    grid-template-columns: 1fr 1fr;
    gap: 24px
  }
}

@media (max-width:640px) {
  .tech {
    grid-template-columns: 1fr 1fr
  }
}

/* Trang Giới thiệu: lưới máy móc & khối chứng nhận (bố cục viết inline trong html-raw) */
#cert .shell > div > * {
  min-width: 0
}

#cert .shell > div > div > div[style*="display: flex"] {
  flex-wrap: wrap
}

@media (max-width:980px) {
  #machines .cards {
    grid-template-columns: 1fr 1fr !important
  }

  #cert .shell > div {
    grid-template-columns: 1fr !important;
    padding: 36px 28px !important
  }
}

@media (max-width:640px) {
  #machines .cards {
    grid-template-columns: 1fr !important
  }

  /* Thư viện ảnh nhà xưởng (3 cột viết inline) */
  .sec div[style*="grid-template-columns: repeat(3, 1fr); gap: 20px"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important
  }

  #cert .shell > div {
    padding: 28px 20px !important
  }

  #cert h2 {
    font-size: 26px !important
  }

  #profile {
    padding: 24px 18px !important
  }
}

/* Điện thoại: nút có chữ dài được xuống dòng thay vì tràn khung */
@media (max-width:640px) {
  .btn {
    white-space: normal;
    text-align: center;
    justify-content: center
  }
}

/* --------------------------------------------------------------------------
   Bộ lọc trang Sản phẩm: trên màn hình nhỏ thu gọn sau nút "Lọc sản phẩm"
   -------------------------------------------------------------------------- */
.side-toggle {
  display: none
}

@media (max-width:980px) {
  .side-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 50px;
    padding: 0 18px;
    border: 1px solid var(--line-2);
    border-radius: var(--r);
    background: #fff;
    color: var(--primary);
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer
  }

  .side-toggle span {
    flex: 1;
    text-align: left
  }

  .side-toggle::after {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-3px);
    transition: transform .2s
  }

  #prodFilter.is-open .side-toggle::after {
    transform: rotate(-135deg) translateY(-2px)
  }

  .side-toggle__n {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-style: normal;
    line-height: 22px;
    text-align: center
  }

  .side-toggle__n[hidden] {
    display: none
  }

  #prodFilter:not(.is-open) > .side__box {
    display: none
  }
}

/* --------------------------------------------------------------------------
   Điện thoại
   -------------------------------------------------------------------------- */
@media (max-width:640px) {

  /* Topbar gọn một dòng: giữ email + ngôn ngữ */
  .topbar .msgs {
    display: none
  }

  .topbar .shell {
    justify-content: space-between
  }

  .langs button {
    min-width: 34px;
    min-height: 30px
  }

  /* Các lưới thẻ dài thành hàng vuốt ngang (trang chủ, lưới ngành trang Sản phẩm) */
  .prod-grid,
  .ind-grid,
  .inds,
  .quotes,
  .news-grid {
    display: grid;
    grid-template-columns: none !important;
    grid-auto-flow: column;
    grid-auto-columns: 84%;
    gap: 14px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gut);
    margin-inline: calc(var(--gut) * -1);
    padding: 4px var(--gut) 10px;
    scrollbar-width: none
  }

  .prod-grid::-webkit-scrollbar,
  .ind-grid::-webkit-scrollbar,
  .inds::-webkit-scrollbar,
  .quotes::-webkit-scrollbar,
  .news-grid::-webkit-scrollbar {
    display: none
  }

  .prod-grid > *,
  .ind-grid > *,
  .inds > *,
  .quotes > *,
  .news-grid > * {
    scroll-snap-align: start
  }

  /* Bảng kết quả tra cứu: nhãn trên, giá trị dưới */
  .res-row {
    flex-direction: column;
    gap: 4px
  }

  .res-row b {
    text-align: left !important
  }

  /* Nút liên hệ nổi nhỏ gọn hơn, ít che nội dung */
  .fab {
    right: 12px;
    bottom: 12px;
    gap: 6px
  }

  .fab a,
  .fab button {
    width: 44px;
    height: 44px
  }

  /* Footer: liên kết dễ chạm hơn */
  .ft-col a {
    padding: 4px 0
  }
}

/* --------------------------------------------------------------------------
   Điện thoại rất nhỏ (≤ 380px, VD iPhone SE)
   -------------------------------------------------------------------------- */
@media (max-width:380px) {
  .topbar .shell > div {
    gap: 10px !important
  }

  .topbar a {
    font-size: 12px
  }

  .langs button {
    min-width: 28px
  }

  .toolbar {
    flex-wrap: wrap
  }

  .toolbar .f {
    width: 100%
  }

  .toolbar .f select {
    flex: 1;
    min-width: 0
  }
}
