/* ==========================================================================
   AVENTARA — Premium Responsive Stylesheet
   Mobile-First & Fluid Tablet Ergonomics (320px - 1440px)
   Guaranteed Zero Cropping & 100% Responsive Layout
   ========================================================================== */

/* --- GLOBAL RESPONSIVE BASE & TOUCH SAFEGUARDS --- */
html, body {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  width: 100% !important;
  -webkit-text-size-adjust: 100%;
}

*, *::before, *::after {
  box-sizing: border-box;
}

img, video, canvas, svg {
  max-width: 100%;
  height: auto;
}

/* Touch ergonomic min tap target */
button, a, input, select, textarea {
  touch-action: manipulation;
}

/* Smooth horizontal touch scroll for all data tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  border-radius: var(--radius-md);
}

.table-responsive table {
  min-width: 650px;
}

/* Base states for Dashboard sidebar components */
.dashboard-sidebar-toggle {
  display: none;
  background: var(--surface-light);
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.dashboard-sidebar-toggle:hover {
  background: var(--surface-border);
  color: var(--primary);
}

.dashboard-sidebar-mobile-header {
  display: none;
}

.dashboard-sidebar-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transition: color var(--transition-fast);
}

.dashboard-sidebar-close:hover {
  color: var(--secondary);
}

.dashboard-sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(13, 15, 26, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1190;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.dashboard-sidebar-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   1. LAPTOPS & TABLET LANDSCAPE (max-width: 1024px)
   ========================================================================== */
@media (max-width: 1024px) {
  :root {
    --header-height: 70px;
  }

  .header-search {
    max-width: 240px;
  }

  .trending-slider {
    grid-template-columns: 1fr;
  }

  .footer-top {
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
  }

  .footer-brand,
  .footer-newsletter {
    grid-column: 1 / -1;
  }

  /* Retain comfortable dashboard sidebar on tablet landscape (220px) */
  .dashboard-layout {
    grid-template-columns: 220px 1fr;
  }

  .dashboard-sidebar {
    padding: 1.5rem 1rem;
    gap: 1.5rem;
  }

  .dashboard-nav-link {
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
  }

  /* Dashboard Report Grids */
  .dashboard-report-overview-grid {
    grid-template-columns: 1fr !important;
  }

  .promotor-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .pos-grid,
  .online-order-grid {
    grid-template-columns: 1fr !important;
  }

  .qr-ticket-body {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .qr-ticket-tear-line,
  .qr-ticket-notch-top,
  .qr-ticket-notch-bottom {
    display: none;
  }
}

/* ==========================================================================
   2. TABLETS PORTRAIT & MEDIUM SCREENS (max-width: 992px)
   ========================================================================== */
@media (max-width: 992px) {
  /* Public Header */
  .header-search,
  .header-nav {
    display: none !important;
  }

  .mobile-menu-toggle {
    display: grid !important;
  }

  /* Promotor Dashboard Header & Off-Canvas Sidebar */
  .dashboard-sidebar-toggle {
    display: inline-flex !important;
  }

  .dashboard-layout {
    display: block !important;
    width: 100% !important;
  }

  .dashboard-sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 290px !important;
    max-width: 85vw !important;
    background: #0E101D !important;
    z-index: 1200 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-shadow: none !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 1.5rem 1.25rem !important;
    border-right: 1px solid var(--surface-border) !important;
  }

  .dashboard-sidebar.mobile-open {
    transform: translateX(0) !important;
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.95) !important;
  }

  .dashboard-sidebar-mobile-header {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding-bottom: 1rem !important;
    margin-bottom: 1.25rem !important;
    border-bottom: 1px solid var(--surface-border) !important;
  }

  .dashboard-main {
    padding: 1.5rem 1.25rem !important;
  }

  /* Hero Featured Spotlight Collapse */
  .hero-featured-spotlight {
    grid-template-columns: 1fr !important;
  }

  .hero-featured-spotlight > div:first-child {
    min-height: 240px !important;
    height: 240px !important;
  }

  .hero-featured-spotlight > div:last-child {
    padding: 2rem 1.5rem !important;
  }

  /* Catalog Layout (events.html) */
  .events-catalog-grid {
    grid-template-columns: 1fr !important;
    gap: 1.75rem !important;
  }

  .filter-sidebar {
    position: static !important;
    width: 100% !important;
    margin-bottom: 1.5rem;
  }

  /* Event Detail Layout (event-detail.html) */
  .event-detail-grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  /* Checkout Layout (payment.html) */
  .checkout-grid {
    grid-template-columns: 1fr !important;
    gap: 2rem !important;
  }

  /* Settings Grid (creator/settings.html) */
  .settings-grid-layout {
    grid-template-columns: 1fr !important;
    gap: 1.75rem !important;
  }
}

/* ==========================================================================
   3. PHONES & SMALL TABLETS (max-width: 768px)
   ========================================================================== */
@media (max-width: 768px) {
  /* --- CRITICAL: ZERO-OVERFLOW NAVBAR FIXES --- */
  .site-header {
    height: auto !important;
    min-height: var(--header-height);
  }

  .header-inner {
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
    gap: 0.5rem !important;
  }

  /* Profile Avatar Button: Keep ONLY Avatar + Chevron on Mobile */
  .profile-trigger-btn {
    padding: 2px 4px 2px 2px !important;
    gap: 0.35rem !important;
    background: transparent !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
  }

  .profile-trigger-btn .profile-label-role,
  .profile-trigger-btn .role-badge-tag {
    display: none !important;
  }

  .profile-trigger-btn .avatar-img {
    width: 32px !important;
    height: 32px !important;
  }

  .profile-trigger-btn i.fa-chevron-down {
    display: inline-block !important;
    font-size: 0.65rem !important;
    color: var(--text-muted) !important;
    margin-right: 2px !important;
  }

  /* Hide SSL Security text from checkout header to prevent squeezing */
  .payment-security-badge {
    display: none !important;
  }

  /* Dashboard Header on Mobile: Two-Row Flex Wrap */
  .dashboard-header-inner {
    flex-wrap: wrap !important;
    height: auto !important;
    padding-top: 0.55rem !important;
    padding-bottom: 0.55rem !important;
  }

  .dashboard-header-inner > div:first-child {
    gap: 0.75rem !important;
  }

  .toko-publik-text {
    display: none !important;
  }

  .portal-badge {
    display: none !important;
  }

  .dashboard-role-container {
    order: 3 !important;
    width: 100% !important;
    justify-content: center !important;
    margin-top: 0.45rem !important;
    padding-top: 0.45rem !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
  }

  .dashboard-role-label {
    display: none !important;
  }

  .dashboard-role-switcher {
    width: 100% !important;
    max-width: 360px !important;
    display: flex !important;
    justify-content: space-between !important;
    padding: 3px !important;
  }

  .role-pill-btn {
    flex: 1 !important;
    text-align: center !important;
    padding: 0.35rem 0.5rem !important;
    font-size: 0.78rem !important;
  }

  /* --- TYPOGRAPHY & SPACING OPTIMIZATIONS --- */
  h1 {
    font-size: clamp(1.4rem, 5vw, 1.85rem) !important;
    line-height: 1.25 !important;
  }

  h2, .section-title {
    font-size: clamp(1.25rem, 4.5vw, 1.6rem) !important;
    line-height: 1.3 !important;
  }

  h3 {
    font-size: clamp(1.05rem, 4vw, 1.25rem) !important;
  }

  .section {
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
  }

  .section-subtitle {
    font-size: 0.85rem !important;
  }

  .hero-search-wrapper {
    flex-direction: column;
    padding: 0.85rem;
    border-radius: var(--radius-lg);
  }

  .hero-search-field {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--surface-border);
    padding: 0.75rem 0.5rem;
  }

  .hero-search-field.no-border {
    border-bottom: none;
  }

  .hero-search-wrapper .btn {
    width: 100%;
    margin-top: 0.5rem;
  }

  .events-grid {
    grid-template-columns: 1fr;
  }

  .event-card-horizontal {
    grid-template-columns: 1fr;
  }

  .event-card-horizontal .event-card-media {
    aspect-ratio: 16 / 10;
  }

  /* Mobile Sticky Bottom Bar for Instant Buy */
  .mobile-sticky-bar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    background: rgba(13, 15, 26, 0.96) !important;
    backdrop-filter: blur(16px) !important;
    -webkit-backdrop-filter: blur(16px) !important;
    border-top: 1px solid var(--surface-border) !important;
    padding: 0.75rem 1.25rem !important;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom)) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    z-index: 990 !important;
    box-shadow: 0 -6px 25px rgba(0, 0, 0, 0.7) !important;
  }

  .mobile-sticky-bar .btn {
    padding: 0.65rem 1.4rem;
    font-size: 0.9rem;
  }

  /* Event Detail Sticky Sidebar inside page content on mobile */
  aside[style*="position: sticky"] {
    position: static !important;
    width: 100% !important;
    margin-bottom: 3.5rem !important;
  }

  /* Profile page layout */
  .profile-settings-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }

  .metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
  }

  .footer-top {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .toast {
    min-width: unset;
    width: 100%;
  }

  .ticket-tier-card {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
  }

  .ticket-tier-pricing {
    text-align: left;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.75rem;
    border-top: 1px solid var(--surface-border);
  }

  .category-tile-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cities-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* KPI values on mobile */
  .kpi-value {
    font-size: 1.25rem !important;
  }

  .kpi-ticket-mini-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ==========================================================================
   4. STANDARD SMARTPHONES (max-width: 576px)
   ========================================================================== */
@media (max-width: 576px) {
  .hide-mobile {
    display: none !important;
  }

  .container,
  .container-wide {
    padding-left: 0.85rem !important;
    padding-right: 0.85rem !important;
  }

  .dashboard-main {
    padding: 1rem 0.75rem !important;
  }

  /* Header compact ergonomics */
  .brand-logo {
    gap: 0.45rem !important;
    font-size: 1.15rem !important;
  }

  .brand-icon {
    width: 30px !important;
    height: 30px !important;
    font-size: 0.95rem !important;
  }

  /* Form two-column collapses */
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns: repeat(2, 1fr)"],
  div[style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Payment method tiles on phone (2x2 grid) */
  .payment-methods-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.65rem !important;
  }

  .payment-method-item {
    padding: 0.75rem 0.35rem !important;
  }

  .payment-method-item i {
    font-size: 1.15rem !important;
  }

  .payment-method-name {
    font-size: 0.72rem !important;
  }

  /* Grand total checkout price */
  #pay-grand-total {
    font-size: 1.45rem !important;
  }

  /* Hero adjustments */
  .hero-featured-spotlight > div:first-child {
    min-height: 190px !important;
    height: 190px !important;
  }

  .hero-featured-spotlight > div:last-child {
    padding: 1.25rem 1rem !important;
  }

  .hero-featured-spotlight h2 {
    font-size: 1.25rem !important;
  }

  /* Dialogs on small screens */
  dialog.custom-dialog {
    width: 95vw !important;
    max-width: 95vw !important;
    margin: auto !important;
    padding: 1.15rem !important;
    border-radius: var(--radius-lg) !important;
  }

  /* Ticket tier selector in POS cashier */
  .ticket-tier-selector {
    grid-template-columns: 1fr !important;
  }

  .promotor-kpi-grid {
    grid-template-columns: 1fr !important;
  }

  .dashboard-page-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.85rem !important;
  }

  .dashboard-page-header .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  .dashboard-filter-bar {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .dashboard-filter-bar div[style*="min-width"] {
    min-width: 100% !important;
    width: 100% !important;
  }
}

/* ==========================================================================
   5. NARROW PHONES (max-width: 380px)
   ========================================================================== */
@media (max-width: 380px) {
  .brand-name {
    font-size: 1.05rem !important;
  }

  .cities-grid {
    grid-template-columns: 1fr !important;
  }

  .category-tile-grid {
    grid-template-columns: 1fr !important;
  }

  .payment-methods-grid {
    grid-template-columns: 1fr !important;
  }

  .role-pill-btn {
    padding: 0.28rem 0.35rem !important;
    font-size: 0.7rem !important;
  }
}
