/* AN KHANG LIFE Mobile Web App UI
   Shared responsive layer for iOS Safari, Android Chrome and installed PWAs.
   Kept separate from page styles so the desktop experience remains unchanged. */
:root {
  --akl-app-orange: #F58220;
  --akl-app-orange-deep: #C85A0A;
  --akl-app-ink: #30251f;
  --akl-app-muted: #76685f;
  --akl-app-line: #eee5de;
  --akl-app-surface: #fff;
  --akl-app-radius: 16px;
  --akl-app-safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
html {
  width: 100%;
  min-width: 320px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 76px;
  scroll-padding-bottom: 88px;
}
body {
  min-width: 320px;
  max-width: 100%;
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-x: none;
}
img, video, iframe { max-width: 100%; }
button, a, input, select, textarea { touch-action: manipulation; }
button, .btn, input[type="button"], input[type="submit"] { min-height: 44px; }
.form-control, .form-select, input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select, textarea {
  max-width: 100%;
}
:focus-visible {
  outline: 3px solid rgba(245,130,32,.38);
  outline-offset: 2px;
}
.table-responsive { -webkit-overflow-scrolling: touch; }
.modal { overscroll-behavior: contain; }
.dropdown-menu { max-width: min(92vw, 380px); }
#backToTop { z-index: 1040; }

/* Phones */
@media (max-width: 767.98px) {
  html, body { width: 100%; }
  body {
    /* Leave enough room for the taller fixed mobile navigation and home indicator. */
    padding-bottom: calc(86px + var(--akl-app-safe-bottom)) !important;
    font-size: 15px;
    line-height: 1.55;
  }
  .container, .container-fluid {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  .container { max-width: 100% !important; }
  .top-bar { display: none !important; }

  /* Compact, stable app header */
  body > nav.navbar, nav.navbar.sticky-top {
    min-height: 58px;
    padding: 6px 0 !important;
    padding-top: max(6px, env(safe-area-inset-top, 0px)) !important;
    z-index: 1050;
  }
  nav.navbar > .container {
    min-height: 46px;
    gap: 8px;
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
  }
  /* Logged-in phone header: hamburger on the left, account controls grouped on the right. */
  nav.navbar > .container > .navbar-toggler {
    order: 0 !important;
    margin: 0 auto 0 0 !important;
    flex: 0 0 40px;
  }
  nav.navbar > .container > .mobile-user-section {
    order: 1 !important;
    margin: 0 0 0 auto !important;
    flex: 0 0 auto;
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    gap: 8px !important;
  }
  nav.navbar > .container > .mobile-user-section .mobile-reward-info {
    margin-right: 0.25rem !important;
    max-width: 96px;
    text-align: right;
  }
  nav.navbar .navbar-brand { margin-right: auto; padding: 2px 0; }
  nav.navbar .logo-main { display: block; max-height: 42px !important; width: auto; max-width: 154px; object-fit: contain; }
  nav.navbar .navbar-toggler {
    width: 44px; height: 44px; min-height: 44px;
    display: inline-grid; place-items: center;
    padding: 0; border-radius: 12px;
  }
  nav.navbar .mobile-user-section { gap: 5px; }
  nav.navbar .mobile-user-section .mobile-reward-info { max-width: 96px; overflow: hidden; }
  nav.navbar .navbar-collapse {
    position: absolute;
    top: 100%; left: 0; right: 0;
    max-height: calc(100dvh - 66px);
    overflow-y: auto;
    padding: 8px 16px 16px;
    background: #fff;
    border-top: 1px solid var(--akl-app-line);
    box-shadow: 0 12px 24px rgba(48,37,31,.12);
    overscroll-behavior: contain;
  }
  nav.navbar .navbar-nav { margin: 0 !important; }
  nav.navbar .navbar-nav .nav-link {
    display: flex; align-items: center;
    min-height: 48px; padding: 11px 12px !important;
    border-bottom: 1px solid #f3eee9;
    font-size: 15px; font-weight: 600;
  }
  nav.navbar .navbar-nav .nav-item:last-child .nav-link { border-bottom: 0; }
  nav.navbar .navbar-nav .dropdown-menu {
    position: static !important; float: none;
    width: 100%; margin: 0 0 8px;
    border: 0; border-radius: 12px;
    background: #fff8f2; box-shadow: none;
  }
  nav.navbar .navbar-nav .dropdown-item { min-height: 44px; padding: 11px 14px; white-space: normal; }
  #notification-menu-collapsed { display: none !important; }

  /* Native-feeling bottom tab bar, including iPhone home-indicator inset */
  #mobileBottomNav.mobile-bottom-nav {
    position: fixed !important;
    left: 0; right: 0; bottom: 0;
    width: 100%; height: calc(74px + var(--akl-app-safe-bottom));
    min-height: calc(74px + var(--akl-app-safe-bottom));
    box-sizing: border-box;
    display: flex !important; align-items: stretch; justify-content: space-around;
    padding: 7px 4px var(--akl-app-safe-bottom) !important;
    background: rgba(255,255,255,.97);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid rgba(95,65,43,.12) !important;
    box-shadow: 0 -5px 22px rgba(48,37,31,.09);
    z-index: 1100;
  }
  #mobileBottomNav .mb-item {
    flex: 1 1 0; min-width: 0; min-height: 62px; height: 100%;
    gap: 5px; justify-content: center;
    color: #76685f; font-size: 10px; font-weight: 600;
    -webkit-tap-highlight-color: transparent;
  }
  #mobileBottomNav .mb-item i { margin: 0; font-size: 19px; line-height: 1.15; }
  #mobileBottomNav .mb-item span:not(.mb-badge) { font-size: 10px; line-height: 1.15; white-space: nowrap; }
  #mobileBottomNav .mb-item.active { color: var(--akl-app-orange-deep) !important; }
  #mobileBottomNav .mb-item.active i { color: var(--akl-app-orange) !important; }
  #mobileBottomNav .mb-item .mb-badge { top: 2px; right: calc(50% - 18px); transform: none; }
  #backToTop { right: 14px !important; bottom: calc(78px + var(--akl-app-safe-bottom)) !important; }

  /* Comfortable reading and card rhythm */
  h1 { font-size: clamp(1.55rem, 6vw, 2rem); line-height: 1.2; }
  h2 { font-size: clamp(1.3rem, 5vw, 1.65rem); line-height: 1.25; }
  .section-title { font-size: 1.55rem !important; line-height: 1.25; margin-bottom: 1.6rem !important; }
  .card, .product-card, .news-card, .benefit-card {
    border-radius: var(--akl-app-radius) !important;
    overflow: hidden;
  }
  .card-body { min-width: 0; }
  .btn, button.btn {
    min-height: 46px; border-radius: 12px;
    padding: 10px 16px; font-weight: 600;
  }
  .form-label { font-size: 14px; font-weight: 600; }
  .form-control, .form-select, input.form-control, select.form-select {
    min-height: 48px; border-radius: 12px; font-size: 16px !important;
    padding: 11px 13px;
  }
  textarea.form-control { min-height: 104px; }
  input[type="checkbox"], input[type="radio"], .form-check-input {
    width: 20px; height: 20px; flex: 0 0 auto;
  }
  .form-check { display: flex; align-items: flex-start; gap: 9px; min-height: 30px; }
  .form-check .form-check-input { margin: 2px 0 0; }
  .form-check .form-check-label { line-height: 1.45; }

  /* Commerce: avoid cramped two-column content and tiny product controls */
  .product-details { padding: 12px 0 24px; }
  .product-image { height: min(78vw, 340px) !important; min-height: 220px; border-radius: 16px; }
  .product-title { font-size: 1.25rem !important; line-height: 1.35; }
  .product-price { font-size: 1.25rem !important; }
  .product-card .card-title { height: auto !important; min-height: 0; font-size: .92rem; line-height: 1.4; }
  .product-card .product-image { height: auto !important; aspect-ratio: 1 / 1; }
  .product-card .product-image img { width: 100%; height: 100%; object-fit: contain; }
  .cart-item { display: flex; flex-wrap: wrap; gap: 10px; }
  .cart-item-quantity { width: 76px !important; min-height: 42px; }
  .cart-summary, .order-summary { border-radius: 16px; padding: 16px; }
  .order-summary { position: static !important; }
  .checkout-section { margin-bottom: 20px; }
  .payment-method { padding: 14px; border-radius: 14px; }
  .table { min-width: 560px; }
  .table-responsive { border-radius: 12px; }
  .breadcrumb { flex-wrap: wrap; font-size: 12px; margin-bottom: 14px; }
  .pagination { flex-wrap: wrap; gap: 4px; }

  /* Account, authentication and long-form content */
  .account-sidebar { margin-bottom: 16px; }
  .account-content { padding: 16px !important; border-radius: 16px; }
  .account-mobile-tabs { top: 60px; margin-left: 0 !important; margin-right: 0 !important; }
  .account-mobile-tabs .tab-btn { min-width: 66px; min-height: 58px; }
  .auth-page { padding-top: 22px !important; padding-bottom: 22px !important; }
  .auth-page .card-body { padding: 22px 16px !important; }
  .auth-container { min-height: auto !important; padding: 22px 0 30px; }
  .auth-card { width: 100%; max-width: 100%; border-radius: 20px; }
  .auth-card-body { padding-left: 18px !important; padding-right: 18px !important; }
  .footer .container { padding-top: 24px !important; padding-bottom: 12px !important; }
  .footer .col-lg-3 { margin-bottom: 22px !important; }
  .footer .footer-logo-panel .footer-logo { max-height: 82px; }
  .bottom-footer { text-align: center; }
  .modal-dialog { margin: 10px !important; }
  .modal-content { border-radius: 18px; overflow: hidden; }
  .toast-notification { min-width: 0; max-width: calc(100vw - 28px); }

  /* Homepage hero and content grids */
  #an-khang-life-home .akl-wrap { width: calc(100% - 32px) !important; }
  #an-khang-life-home .akl-cover__carousel .carousel-item { height: clamp(260px, 74vw, 390px) !important; }
  #an-khang-life-home .akl-cover__bar-inner { gap: 14px; }
  #an-khang-life-home .akl-cover__bar-actions { flex-wrap: wrap; }
  #an-khang-life-home .akl-btn { min-height: 46px; }
  #an-khang-life-home .akl-features { grid-template-columns: repeat(2, minmax(0,1fr)); }
  #an-khang-life-home .akl-feature { min-width: 0; }
  .warehouse-banner img { width: 100%; height: auto; }
}

/* Small phones: preserve readable controls without horizontal overflow */
@media (max-width: 359.98px) {
  .container, .container-fluid { padding-left: 12px !important; padding-right: 12px !important; }
  #mobileBottomNav .mb-item span:not(.mb-badge) { font-size: 9px; }
  #mobileBottomNav .mb-item i { font-size: 18px; }
  .mobile-reward-info { display: none !important; }
  .account-mobile-tabs .tab-btn { min-width: 60px; padding: 9px 6px; }
}

/* Tablets: retain desktop navigation while using touch-friendly spacing */
@media (min-width: 768px) and (max-width: 991.98px) {
  body { padding-bottom: 24px; }
  .container { max-width: 100%; padding-left: 22px; padding-right: 22px; }
  nav.navbar .logo-main { max-height: 46px; }
  .navbar-nav .nav-link { padding-left: .75rem; padding-right: .75rem; }
  .product-image { height: 300px; }
  .account-content { padding: 20px; }
}

/* iOS standalone display and Android installed PWA */
@media (display-mode: standalone) {
  html { scroll-padding-top: 64px; }
  body { -webkit-user-select: text; }
  nav.navbar.sticky-top { padding-top: max(6px, env(safe-area-inset-top, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* iPad and touch tablets: show the same bottom app navigation as phones */
@media (min-width: 768px) and (max-width: 1366px) {
  body {
    padding-bottom: calc(82px + var(--akl-app-safe-bottom)) !important;
  }
  #mobileBottomNav.mobile-bottom-nav {
    display: flex !important;
    position: fixed !important;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: calc(72px + var(--akl-app-safe-bottom));
    min-height: calc(72px + var(--akl-app-safe-bottom));
    box-sizing: border-box;
    align-items: stretch;
    justify-content: space-around;
    padding: 7px 5% var(--akl-app-safe-bottom) !important;
    background: rgba(255,255,255,.97);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid rgba(95,65,43,.12) !important;
    box-shadow: 0 -5px 22px rgba(48,37,31,.09);
    z-index: 1100;
  }
  #mobileBottomNav .mb-item {
    flex: 1 1 0;
    min-width: 0;
    min-height: 60px;
    height: 100%;
    gap: 5px;
    justify-content: center;
    color: #76685f;
    font-size: 12px;
    font-weight: 600;
  }
  #mobileBottomNav .mb-item i {
    margin: 0;
    font-size: 21px;
    line-height: 1.15;
  }
  #mobileBottomNav .mb-item span:not(.mb-badge) {
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
  }
  #mobileBottomNav .mb-item.active {
    color: var(--akl-app-orange-deep) !important;
  }
  #mobileBottomNav .mb-item.active i {
    color: var(--akl-app-orange) !important;
  }
  #mobileBottomNav .mb-item .mb-badge {
    top: 5px;
    right: calc(50% - 20px);
    transform: none;
  }
  #backToTop {
    bottom: calc(92px + var(--akl-app-safe-bottom)) !important;
  }
}

/* iPad cart is available in the top navigation, not duplicated in bottom tabs */
@media (min-width:768px) and (max-width:1366px) {
  #mobileBottomNav [data-nav="cart"] { display:none !important; }
}


/* Final phone bottom-nav rules: one compact fixed bar shared by every page.
   Keep this block last so page-specific styles cannot resize or move the bar. */
@media (max-width: 767.98px) {
  html, body { overflow-x: clip; }
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important; }
  body > #mobileBottomNav.mobile-bottom-nav {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    height: calc(50px + env(safe-area-inset-bottom, 0px)) !important;
    min-height: calc(50px + env(safe-area-inset-bottom, 0px)) !important;
    margin: 0 !important;
    padding: 2px 4px env(safe-area-inset-bottom, 0px) !important;
    box-sizing: border-box !important;
    align-items: stretch !important;
    justify-content: space-around !important;
    transform: none !important;
    background: #fff !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    z-index: 1100 !important;
  }
  body > #mobileBottomNav .mb-item {
    min-height: 0 !important;
    height: 100% !important;
    gap: 1px !important;
    justify-content: center !important;
    font-size: 10px !important;
    line-height: 1.05 !important;
  }
  body > #mobileBottomNav .mb-item i {
    margin: 0 0 1px !important;
    font-size: 16px !important;
    line-height: 1.05 !important;
  }
  body > #mobileBottomNav .mb-item span:not(.mb-badge) {
    font-size: 9px !important;
    line-height: 1.05 !important;
  }
}
