/* Mobile-friendly enhancements for Ultra IPTV store */

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

body {
  -webkit-tap-highlight-color: transparent;
}

/* ── Tablet & below ── */
@media (max-width: 768px) {
  .app-shell {
    margin: 0;
    padding: 0;
    max-width: none;
  }

  .wrap {
    border: none;
    border-radius: 0;
    flex-direction: column;
    min-height: 100dvh;
    min-height: 100vh;
    overflow: visible;
  }

  /* Sticky horizontal nav */
  .side {
    flex-direction: row;
    width: 100%;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: sticky;
    top: 0;
    z-index: 40;
    flex-shrink: 0;
  }

  .side::-webkit-scrollbar {
    display: none;
  }

  .side-brand {
    border-bottom: none;
    border-right: 0.5px solid #ffffff12;
    flex-shrink: 0;
    padding: 0.85rem 1rem;
  }

  .side-brand .logo {
    font-size: 17px;
    white-space: nowrap;
  }

  .side-brand .sub {
    display: none;
  }

  .side-section {
    border-bottom: none;
    flex-direction: row;
    padding: 0;
    display: flex;
    flex-shrink: 0;
  }

  .side-section-label {
    display: none;
  }

  .nav-item {
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    border-left: none;
    padding: 0.85rem 1rem;
    min-height: 48px;
    font-size: 13px;
    flex-shrink: 0;
  }

  .nav-item.active {
    border-bottom-color: #e53935;
    border-left: none;
  }

  .side-bottom {
    display: none;
  }

  /* Main content */
  .main {
    overflow-y: visible;
    flex: 1;
    min-height: 0;
  }

  .top-bar {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    align-items: flex-start;
  }

  .top-bar h1 {
    font-size: 17px;
    line-height: 1.25;
    flex: 1 1 100%;
  }

  .top-bar .desc {
    font-size: 11.5px;
    line-height: 1.4;
    flex: 1 1 100%;
    margin-top: -0.25rem;
  }

  .top-bar-right {
    flex-shrink: 0;
  }

  .content {
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  /* Product grid */
  .grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card:hover {
    transform: none;
  }

  .card-inner {
    padding: 1rem;
  }

  .card-head {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .card-title {
    font-size: 16px;
    flex: 1 1 auto;
    min-width: 0;
  }

  .card-foot {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .price-tag {
    font-size: 22px;
  }

  .buy-btn {
    padding: 10px 16px;
    font-size: 13px;
    min-height: 44px;
    flex: 1 1 auto;
    justify-content: center;
  }

  /* Checkout modal */
  .modal-bg {
    position: fixed !important;
    inset: 0 !important;
    border-radius: 0;
    z-index: 100;
    align-items: flex-end;
    padding: 0;
  }

  .modal-bg.open {
    display: flex;
  }

  .modal {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    margin: 0;
  }

  .modal-hd {
    padding: 1rem 1rem 0.85rem;
  }

  .modal-body {
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  .plan-chip {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .confirm-btn {
    min-height: 48px;
    font-size: 15px;
    padding: 14px;
  }

  /* Prevent iOS zoom on form focus */
  .field input,
  .field select,
  .field textarea {
    font-size: 16px;
  }

  /* Admin panel */
  .admin-shell {
    flex-direction: column;
  }

  .admin-side {
    flex-direction: row;
    width: 100%;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: sticky;
    top: 0;
    z-index: 40;
    flex-shrink: 0;
  }

  .admin-side::-webkit-scrollbar {
    display: none;
  }

  .admin-side .logo {
    border-bottom: none;
    border-right: 0.5px solid #ffffff12;
    padding: 0 1rem 0 0;
    font-size: 16px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .admin-side nav {
    flex-direction: row;
    gap: 0;
    padding: 0 0 0 0.75rem;
    display: flex;
    flex-shrink: 0;
  }

  .admin-main {
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  .admin-card {
    padding: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-h1 {
    font-size: 19px;
  }

  .admin-h2 {
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 15px;
  }

  .table {
    min-width: 560px;
    font-size: 12px;
  }

  .table th,
  .table td {
    padding: 8px 10px;
  }

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

  .row input,
  .row select {
    width: 100% !important;
    min-height: 44px;
    font-size: 16px !important;
  }

  .btn {
    min-height: 40px;
    justify-content: center;
  }

  .login-shell {
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  }

  .login-card {
    padding: 1.5rem;
  }

  /* Inline 2-column grids inside modals */
  .modal-body [style*="gridTemplateColumns"] {
    grid-template-columns: 1fr !important;
  }
}

/* ── Small phones ── */
@media (max-width: 480px) {
  .top-bar h1 {
    font-size: 16px;
  }

  .card-foot {
    flex-direction: column;
    align-items: stretch;
  }

  .buy-btn {
    width: 100%;
  }

  .price-tag {
    font-size: 20px;
  }

  .success-wrap {
    padding: 1.5rem 1rem;
  }

  .success-wrap i {
    font-size: 36px;
  }
}

/* ── Tablet landscape: 2-column grid ── */
@media (min-width: 481px) and (max-width: 768px) {
  .grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Disable hover lift on touch devices */
@media (hover: none) and (pointer: coarse) {
  .card:hover {
    transform: none;
    border-color: var(--color-border-tertiary);
  }
}
