/* Mobile & responsive enhancements — loveriette */

/* ---- Global touch & readability ---- */
@media (max-width: 1024px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    overflow-x: hidden;
  }

  body {
    overflow-x: hidden;
    max-width: 100%;
  }

  input:not(#search-input):not(.search-bar input),
  select,
  textarea,
  .admin-field input,
  .admin-field select,
  .admin-field textarea,
  .buyer-report-field input,
  .buyer-report-field textarea {
    font-size: 1rem;
  }

  .search-bar input,
  #search-input {
    font-size: 16px;
  }

  .btn-primary,
  .btn-view,
  .btn-upload,
  .admin-btn,
  .buyer-dash-nav-btn,
  .buyer-action-btn,
  .nav-toggle,
  .buyer-dash-menu-toggle,
  .admin-menu-toggle {
    min-height: 44px;
    transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
  }

  .btn-primary:active,
  .btn-view:active,
  .admin-btn:active,
  .buyer-action-btn:active {
    transform: scale(0.98);
  }

  img,
  .brand-logo-shell,
  .store-brand-logo,
  .admin-brand-logo-img,
  .buyer-report-thumb img {
    max-width: 100%;
    height: auto;
  }
}

/* ---- Toast: mobile-friendly ---- */
@media (max-width: 768px) {
  #toast-container {
    top: auto;
    bottom: calc(0.85rem + env(safe-area-inset-bottom));
    right: max(0.75rem, env(safe-area-inset-right));
    left: max(0.75rem, env(safe-area-inset-left));
    align-items: stretch;
    z-index: 3000;
  }

  .toast {
    min-width: 0;
    max-width: none;
    width: 100%;
    border-radius: 12px;
    justify-content: center;
    text-align: center;
    transform: translateY(0.75rem);
  }

  .toast.show {
    transform: translateY(0);
  }

  .toast-message {
    flex: 1;
    text-align: center;
  }
}

/* ---- Buyer dashboard mobile ---- */
@media (max-width: 768px) {
  .buyer-dash-sticky-head {
    position: sticky;
    top: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 1rem;
    padding: 0.65rem 0.25rem 0.75rem;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    transition: background 0.25s ease, border-color 0.25s ease;
  }

  .buyer-dash-sticky-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
    flex: 1;
    min-width: 0;
  }

  .buyer-dash-layout.sidebar-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 150;
    animation: mobile-fade-in 0.28s ease;
  }

  .buyer-dash-sidebar {
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
  }

  .buyer-dash-main {
    padding-top: 0.35rem;
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    max-width: none;
  }

  #buyer-dash-main:not([hidden]) {
    animation: dash-welcome-fade-in 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .dash-welcome-area {
    animation: dash-home-rise 0.5s cubic-bezier(0.4, 0, 0.2, 1) backwards;
  }

  .buyer-dash-panel-head {
    animation: dash-home-rise 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.05s backwards;
  }

  .buyer-dash-stats-hero {
    animation: dash-home-rise 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.1s backwards;
  }

  .buyer-dash-menu-toggle {
    position: static;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem;
    flex-shrink: 0;
  }

  .buyer-dash-stats {
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
  }

  .buyer-dash-stats-hero .buyer-stat-balance {
    grid-column: 1 / -1;
  }

  .buyer-wallet-filters {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .buyer-wallet-list,
  .buyer-purchase-list,
  .buyer-reports-list {
    gap: 0.65rem;
  }

  .buyer-purchase-card,
  .buyer-wallet-row,
  .buyer-report-card {
    border-radius: 12px;
  }

  .buyer-dash-panel-head h1 {
    font-size: 1.15rem;
  }

  .buyer-dash-panel-head p {
    font-size: 0.85rem;
  }

  .buyer-action-btn,
  .buyer-dash-nav-btn {
    font-size: 0.85rem;
  }

  .buyer-report-modal-card,
  .buyer-purchase-modal-card {
    width: calc(100% - 1.5rem);
    max-height: calc(100vh - 2rem);
    margin: 1rem auto;
    border-radius: 14px;
  }

  .buyer-report-modal-body,
  .buyer-purchase-modal-body {
    max-height: calc(100vh - 10rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@keyframes mobile-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes dash-home-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Storefront mobile: no horizontal scroll ---- */
@media (max-width: 768px) {
  .top-nav {
    padding-bottom: 0.35rem;
  }

  .site-header {
    padding-top: 2rem;
    padding-bottom: 2.25rem;
    min-height: 280px;
    border-radius: 20px;
  }

  .hero-section {
    margin-bottom: 2rem;
    padding: 0.5rem 0.75rem 0;
  }

  .store-btn {
    margin-bottom: 1.5rem;
  }

  .site-header-title,
  .site-header h1.site-header-title {
    margin-bottom: 1.5rem;
    max-width: 11.5rem;
  }

  .hero-line-group {
    flex-direction: column;
  }

  .hero-line-group .hero-line {
    display: block;
  }

  .search-bar {
    margin-bottom: 2.25rem;
  }

  .search-input-wrap {
    margin-bottom: 1.5rem;
  }

  .catalog-title {
    margin-top: 0.5rem;
    margin-bottom: 1.15rem;
  }

  main .products {
    padding-top: 0.25rem;
  }

  .top-nav,
  .hero-section,
  .search-bar,
  main,
  .catalog-header,
  .products,
  .site-footer {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
    box-sizing: border-box;
  }

  .site-footer {
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }

  .footer-socials,
  .footer-links {
    flex-wrap: wrap;
    justify-content: center;
    max-width: 100%;
  }
}

/* ---- Admin mobile ---- */
@media (max-width: 1024px) {
  .admin-table-wrap {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
    margin-bottom: 0.5rem;
  }

  .admin-table {
    min-width: 640px;
  }

  .admin-report-note-cell {
    min-width: 8rem;
  }
}

@media (max-width: 860px) {
  .admin-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    margin: -0.25rem -0.5rem 1rem;
    padding: 0.65rem 0.5rem;
    background: color-mix(in srgb, var(--a-bg) 94%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--a-border);
  }

  .admin-menu-toggle {
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
  }

  .admin-topbar h1 {
    font-size: 1.15rem;
    min-width: 0;
  }

  .admin-layout.sidebar-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 150;
  }

  .admin-sidebar {
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .admin-main {
    padding-left: max(0.5rem, env(safe-area-inset-left));
    padding-right: max(0.5rem, env(safe-area-inset-right));
  }

  .admin-stats {
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
  }

  .admin-modal-card {
    width: calc(100% - 1rem);
    max-height: calc(100vh - 2rem);
    margin: 1rem auto;
  }

  .admin-modal-body {
    max-height: calc(100vh - 10rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-form-grid {
    grid-template-columns: 1fr;
  }

  .admin-inv-variant-list--nested {
    padding-left: 0.5rem;
  }

  .admin-order-tabs {
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .admin-order-tab {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.8rem;
    padding: 0.45rem 0.55rem;
  }

  .admin-btn,
  .admin-btn-ghost {
    font-size: 0.85rem;
  }

  .admin-field input,
  .admin-field select,
  .admin-field textarea {
    font-size: 1rem;
  }

  .admin-brand-name {
    font-size: 1rem;
  }

  .admin-nav-btn {
    font-size: 0.9rem;
  }

  .admin-table-actions {
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .admin-table-actions .admin-btn {
    min-height: 36px;
    padding: 0.35rem 0.55rem;
    font-size: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
    transition: none !important;
  }

  .hero-bg-app,
  .hero-decor-panel,
  .hero-decor-wave,
  .hero-decor-orbit,
  .hero-decor-waveform,
  .hero-decor-tile--grid {
    animation: none;
  }

  .hero-bg-app {
    opacity: 0.88;
  }

  .hero-decor-waveform span {
    animation: none;
  }

  .brand-logo-item {
    animation: none;
  }

  .dash-welcome-area,
  .buyer-dash-panel-head,
  .buyer-dash-stats-hero,
  #buyer-dash-main:not([hidden]) {
    animation: none !important;
  }

  .admin-nav-btn {
    transition: background 0.2s ease, color 0.2s ease;
  }

  .admin-nav-btn:hover {
    transform: none;
  }
}

/* ---- Shop page mobile ---- */
@media (max-width: 768px) {
  body.page-shop {
    overflow-x: hidden;
    max-width: 100vw;
  }

  body.page-shop .service-hero--flirty {
    padding: 1.15rem 0.85rem 0.35rem;
    max-width: 100%;
    box-sizing: border-box;
  }

  body.page-shop .service-hero-flirt-title {
    font-size: clamp(1.65rem, 8vw, 2.15rem);
  }

  body.page-shop .service-hero-flirt-tagline {
    font-size: 0.82rem;
    padding: 0 0.15rem;
    line-height: 1.5;
  }

  body.page-shop .search-bar {
    margin: 0 auto 1.15rem;
    padding: 0 0.75rem;
    max-width: 100%;
    box-sizing: border-box;
  }

  body.page-shop .search-input-wrap {
    margin-bottom: 0.85rem;
  }

  body.page-shop .search-bar input,
  body.page-shop #search-input {
    font-size: 16px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  body.page-shop .filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    max-width: 100%;
  }

  body.page-shop .filter-btn {
    flex: 0 0 auto;
    width: auto;
    max-width: 100%;
    padding: 0.38rem 0.72rem;
    font-size: 0.8125rem;
    white-space: nowrap;
  }

  body.page-shop .catalog-header {
    padding: 0 0.75rem;
  }

  body.page-shop .catalog-title {
    font-size: 1rem;
    margin: 0.5rem 0 0.65rem;
  }

  body.page-shop main {
    padding: 0 0 1.25rem;
    max-width: 100%;
    overflow-x: clip;
  }

  body.page-shop main .products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
    padding: 0 0.75rem 0.5rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  body.page-shop .catalog-card {
    min-width: 0;
  }

  body.page-shop .catalog-card-link {
    padding: 0.45rem 0.45rem 0.4rem;
  }

  body.page-shop .catalog-card-name {
    font-size: 0.75rem;
  }

  body.page-shop .catalog-desc {
    font-size: 0.68rem;
    -webkit-line-clamp: 2;
  }

  body.page-shop .catalog-card-icon .logo {
    width: 40px;
    height: 40px;
  }

  body.page-shop #shop-share.page-share-bar {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}

@media (max-width: 380px) {
  body.page-shop main .products {
    gap: 0.4rem;
  }

  body.page-shop .catalog-card-name {
    font-size: 0.7rem;
  }
}
