/* TCA Mobile — tối ưu điện thoại & tablet nhỏ */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body.tca-page,
body.store-page,
body.dash-page {
  overflow-x: clip;
  max-width: 100%;
}

/* ── Chạm & safe area ── */
@media (max-width: 767px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
  select,
  textarea {
    font-size: max(16px, 1rem) !important;
  }

  a,
  button,
  [role="button"],
  .store-dock__item,
  .bottom-nav__item,
  .cm-bottom-nav__item,
  .dp-dock__item,
  .action-card,
  .menu-item,
  .hero-action-btn,
  .dp-method {
    -webkit-tap-highlight-color: rgba(166, 124, 26, 0.14);
    touch-action: manipulation;
  }

  .content,
  .dashboard-main,
  .store-main,
  .store-wrap,
  .dp-main,
  .wd-main,
  .co-main,
  .cart-main,
  .mo-main,
  .hx-main {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }
}

/* ── Dashboard ── */
@media (max-width: 767px) {
  body.dash-page {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }

  .header {
    padding-left: max(0.5rem, env(safe-area-inset-left));
    padding-right: max(0.5rem, env(safe-area-inset-right));
    padding-top: env(safe-area-inset-top, 0px);
  }

  .brand-lockup__name {
    font-size: clamp(0.8125rem, 3.8vw, 0.9375rem);
    max-width: 42vw;
  }

  .brand-lockup__tag {
    display: none;
  }

  .hero-bezel.bezel-shell {
    padding: 0.25rem;
    margin-bottom: var(--space-md);
  }

  .hero-card {
    padding: 0.85rem;
    border-radius: 1rem;
  }

  .hero-content {
    gap: 0.75rem;
  }

  .hero-name {
    font-size: 1.125rem;
  }

  .hero-avatar {
    width: 2.75rem;
    height: 2.75rem;
  }

  .rank-medallion {
    padding: 0.4rem 0.55rem;
  }

  .rank-medallion__name {
    font-size: 0.8125rem;
  }

  .hero-balance-block {
    padding: 0.75rem;
  }

  .balance-amount-inline {
    font-size: clamp(1.45rem, 7.5vw, 1.85rem) !important;
    line-height: 1.1;
  }

  .balance-amount-inline--charm {
    font-size: clamp(1.2rem, 6vw, 1.5rem) !important;
  }

  .dash-balance-hint {
    font-size: 0.625rem;
    line-height: 1.4;
  }

  /* Nút Nạp/Rút — luôn 2 cột trên điện thoại */
  .hero-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.45rem;
  }

  .hero-action-btn,
  .hero-action-btn--pill {
    min-height: 2.875rem;
    padding: 0.45rem 0.5rem 0.45rem 0.6rem;
    gap: 0.35rem;
  }

  .hero-action-btn__label {
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.2;
  }

  .hero-action-btn__icon {
    width: 1.65rem;
    height: 1.65rem;
    font-size: 0.75rem;
  }

  .dash-shortcuts__scroll .action-card {
    flex: 0 0 4.85rem;
    min-height: 4.25rem;
    padding: 0.5rem 0.35rem;
  }

  .dash-shortcuts__scroll .action-icon {
    width: 2.4rem;
    height: 2.4rem;
    font-size: 0.95rem;
  }

  .dash-shortcuts__scroll .action-label {
    font-size: 0.625rem;
    font-weight: 600;
  }

  .stat-card {
    padding: 0.65rem 0.75rem;
  }

  .stat-value {
    font-size: 1.0625rem;
  }

  .stat-label {
    font-size: 0.625rem;
  }

  .bb-dash-banner__inner {
    padding: 0.85rem;
  }

  .bb-dash-banner__title {
    font-size: 1.0625rem;
    line-height: 1.25;
  }

  .bb-dash-banner__desc {
    font-size: 0.8125rem;
    line-height: 1.45;
  }

  .menu-modal__panel {
    max-height: min(88vh, 640px);
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  .menu-item {
    min-height: 3.125rem;
    padding: 0.75rem;
  }

  .notification-dropdown {
    left: max(0.75rem, env(safe-area-inset-left));
    right: max(0.75rem, env(safe-area-inset-right));
  }
}

/* Desktop: 4 nút hero một hàng */
@media (min-width: 768px) {
  .hero-panel--actions .hero-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* ── Cửa hàng ── */
@media (max-width: 767px) {
  body.store-page {
    padding-bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px));
  }

  .store-nav .nav-container {
    border-radius: 0;
    box-shadow: none;
    border: none;
    border-bottom: 1px solid rgba(26, 24, 20, 0.06);
  }

  .store-dock {
    left: 0;
    right: 0;
    padding-left: max(0.35rem, env(safe-area-inset-left));
    padding-right: max(0.35rem, env(safe-area-inset-right));
    padding-bottom: max(0.35rem, env(safe-area-inset-bottom));
  }

  .store-dock__item {
    min-height: 3rem;
    padding: 0.2rem 0.15rem;
  }

  .store-dock__icon {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.1rem;
  }

  .store-dock__label {
    font-size: 0.625rem !important;
    font-weight: 600;
    line-height: 1.15;
  }

  .product-grid {
    gap: 0.65rem;
  }

  .product-card__title {
    font-size: 0.8125rem;
    line-height: 1.35;
  }
}

/* ── Nạp / rút tiền ── */
@media (max-width: 767px) {
  .dp-nav .logo-text,
  .wd-nav .logo-text {
    font-size: clamp(0.75rem, 3.5vw, 0.9375rem);
    max-width: 38vw;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .dp-hero h1,
  .wd-hero h1 {
    font-size: clamp(1.375rem, 5.5vw, 1.75rem);
  }

  .dp-method {
    min-height: auto;
  }

  .dp-method__inner {
    padding: 0.85rem !important;
    gap: 0.65rem;
  }

  .dp-method__name {
    font-size: 0.9375rem;
  }

  .dp-method__desc {
    font-size: 0.8125rem;
    line-height: 1.4;
  }

  .dp-dock__item,
  .dp-dock__item span {
    font-size: 0.625rem;
    font-weight: 600;
  }
}

/* ── Bottom nav chung ── */
@media (max-width: 767px) {
  /* Island nổi — không để nền vuông của .bottom-nav lộ ra */
  .bottom-nav:has(.bottom-nav__island) {
    background: transparent !important;
    border-top: none !important;
    box-shadow: none !important;
  }

  .bottom-nav__item,
  .bottom-nav__item i {
    min-height: 2.75rem;
  }

  .bottom-nav__item span {
    font-size: 0.625rem;
    font-weight: 600;
  }

  .cm-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .cm-bottom-nav__item {
    min-height: 3rem;
    flex: 1;
  }
}

/* ── Điện thoại rất nhỏ ── */
@media (max-width: 359px) {
  .hero-action-btn__label {
    font-size: 0.6875rem;
  }

  .dash-shortcuts__scroll .action-card {
    flex: 0 0 4.35rem;
  }

  .stats-grid {
    gap: 0.4rem;
  }
}

/* ── Nghi lễ ── */
@media (max-width: 767px) {
  .rl-wrap,
  .rb-page {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
    padding-bottom: calc(3rem + env(safe-area-inset-bottom, 0px));
  }

  .rl-nav {
    top: env(safe-area-inset-top, 0.5rem);
    margin-top: max(0.5rem, env(safe-area-inset-top));
    padding: 0.5rem 0.65rem;
    border-radius: 1rem;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem 0.65rem;
  }

  .rl-nav a {
    font-size: 0.8125rem;
    padding: 0.35rem 0.25rem;
  }

  .rl-hero {
    min-height: auto;
    padding: 1rem 0 2rem;
  }

  .rl-hero h1 {
    font-size: clamp(1.5rem, 7vw, 2rem);
    line-height: 1.15;
  }
}

/* ── Cộng đồng ── */
@media (max-width: 767px) {
  .cm-main,
  .cm-main--page {
    padding: 0.75rem;
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
  }

  .cm-compose {
    padding: 0.75rem;
  }

  .cm-compose__input {
    min-height: 3.5rem;
    font-size: max(16px, 0.92rem) !important;
  }

  .cm-post {
    padding: 0.85rem;
  }
}

/* ── Landscape phone ── */
@media (max-width: 767px) and (orientation: landscape) {
  .menu-modal__panel {
    max-height: 92vh;
  }

  .hero-actions {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
}
