/**
 * Client + dealer mobile layout (single file — change here only).
 * Expects :root --border, --panel, --text, --text-dim, --accent on public pages.
 */

/* dealer-register.php */
@media (max-width: 780px) {
  .register-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .register-aside {
    display: none;
  }
}

/* ── Prevent horizontal overflow on small viewports ── */
@media (max-width: 768px) {
  html {
    overflow-x: hidden;
  }

  body {
    overflow-x: hidden;
  }
}

/* ── Hamburger (public nav) ── */
.mobile-nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: #ffffff;
  border-radius: 0.6rem;
  width: 40px;
  height: 40px;
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.mobile-nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: #000000;
  border-radius: 2px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  transition: all 0.3s ease;
}

.mobile-nav-toggle span:nth-child(1) {
  top: 11px;
}
.mobile-nav-toggle span:nth-child(2) {
  top: 19px;
}
.mobile-nav-toggle span:nth-child(3) {
  top: 27px;
}

.mobile-nav-toggle.active span:nth-child(1) {
  top: 19px;
  transform: translateX(-50%) rotate(45deg);
}
.mobile-nav-toggle.active span:nth-child(2) {
  opacity: 0;
}
.mobile-nav-toggle.active span:nth-child(3) {
  top: 19px;
  transform: translateX(-50%) rotate(-45deg);
}

/* about.php — hero stacks below 992px */
@media (max-width: 992px) {
  .page-hero {
    grid-template-columns: 1fr;
    padding: 2rem;
  }

  .page-hero-media {
    order: -1;
    min-height: 220px;
  }
}

/* cart.php — layout below 992px */
@media (max-width: 992px) {
  .cart-container {
    grid-template-columns: 1fr;
  }

  .cart-summary {
    position: relative;
    top: 0;
  }

  .cart-item-card {
    grid-template-columns: 120px 1fr;
    gap: 1rem;
  }

  .cart-item-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
  }
}

/* Products catalog split (products.php) */
@media (max-width: 900px) {
  .catalog {
    grid-template-columns: 1fr;
  }

  .product-list {
    max-height: none;
  }
}

@media (max-width: 768px) {
  nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1rem;
    gap: 0;
  }

  .mobile-nav-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    order: 3;
  }

  nav > .logo {
    order: 1;
    font-size: 1.1rem;
  }

  .nav-right {
    order: 2;
    gap: 0.5rem;
    justify-self: auto;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    order: 4;
    gap: 0;
    padding: 0.75rem 0 0.5rem;
    border-top: 1px solid var(--border);
    margin-top: 0.75rem;
  }

  body.nav-open .nav-links {
    display: flex;
  }

  .nav-links li {
    width: 100%;
  }

  .nav-links a {
    width: 100%;
    padding: 0.75rem 0.5rem;
    font-size: 1rem;
    border-radius: 0.5rem;
    transition: background 0.15s ease;
  }

  .nav-links a:hover {
    background: rgba(0, 0, 0, 0.04);
  }

  .dropdown-menu {
    position: static;
    margin-top: 0;
    border: none;
    box-shadow: none;
    padding: 0 0 0 1rem;
    display: none;
    min-width: 0;
    border-radius: 0;
    background: transparent;
  }

  .dropdown.mobile-open .dropdown-menu {
    display: flex;
  }

  .dropdown:hover .dropdown-menu {
    display: none;
  }

  .dropdown.mobile-open:hover .dropdown-menu {
    display: flex;
  }

  .dropdown-menu a {
    padding: 0.6rem 0.5rem;
    font-size: 0.95rem;
  }

  main {
    padding: 2rem 1rem;
  }

  .page-hero {
    padding: 1.5rem;
  }

  .page-hero h1 {
    font-size: 1.6rem;
  }

  /* Home (index.php) */
  .hero {
    padding: 2rem 1rem 1.5rem;
    gap: 1.5rem;
  }

  .hero-content h1 {
    font-size: 1.8rem;
  }

  .hero-actions {
    flex-direction: column;
    gap: 0.75rem;
  }

  .hero-actions .btn {
    text-align: center;
    width: 100%;
  }

  .hero-card {
    padding: 1.25rem;
  }

  .hero-card h3 {
    font-size: 1.3rem;
  }

  .hero-metrics {
    flex-direction: column;
    gap: 0.75rem;
  }

  .products-container {
    margin: 1.5rem 0;
    padding: 0;
  }

  .scroll-button {
    display: none;
  }

/* Home: horizontal product strip (#productsGrid inside .products-container) */
  .products-container .products-grid {
    gap: 1rem;
    padding: 0.5rem 0 1.5rem;
  }

  /* Home only: fixed-width cards for carousel */
  #productsGrid .product-card {
    min-width: min(280px, 92vw);
    max-width: min(280px, 92vw);
    padding: 1rem;
    box-sizing: border-box;
  }

  #productsGrid .product-card img {
    height: 160px;
  }

  #productsGrid .product-card h3 {
    font-size: 1.2rem;
  }

  #productsGrid .product-body {
    min-height: 120px;
    max-height: 120px;
  }

  #productsGrid .product-meta {
    font-size: 0.75rem;
  }

  #productsGrid .price-row {
    font-size: 0.85rem;
  }

  .filter-bar,
  .grid-filter-bar {
    gap: 0.4rem;
  }

  .filter-chip {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
  }

  section {
    padding: 2rem 1rem;
    box-sizing: border-box;
    max-width: 100%;
  }

  .section-heading h2 {
    font-size: 1.5rem;
  }

  /* Products listing (products.php) */
  .category-tiles {
    padding: 1rem;
    max-width: 100%;
    box-sizing: border-box;
  }

  .category-tiles-container {
    padding: 0 44px;
    max-width: 100%;
    box-sizing: border-box;
  }

  .category-scroll-btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .category-card {
    min-width: min(180px, 100%);
    max-width: 100%;
    padding: 1.25rem 1rem;
    box-sizing: border-box;
  }

  .category-card-icon {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
  }

  /* products.php listing */
  #showcaseGrid.products-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.25rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  #showcaseGrid .product-card {
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  #showcaseGrid .product-card-image-wrapper {
    height: 170px;
  }

  #showcaseGrid .product-card-content {
    padding: 1.1rem 1rem 1.2rem;
  }

  #showcaseGrid .product-card h3 {
    font-size: 1.15rem;
  }

  #showcaseGrid .product-card-description {
    font-size: 0.9rem;
  }

  /* Shared product card content (narrow screens): avoid forced overflow */
  .product-meta {
    min-width: 0;
  }

  .price-row {
    min-width: 0;
  }

  .dealer-in-stock-filter {
    font-size: 0.78rem;
    padding-left: 0.5rem;
  }

  .cart-panel {
    width: 100%;
    right: -100%;
  }

  .dealer-auth-btn {
    font-size: 0.75rem;
    padding: 0.4rem 0.7rem;
  }

  #cartToggle {
    font-size: 0.8rem;
    padding: 0.4rem 0.7rem;
  }

  #logoutBtn {
    font-size: 0.75rem;
    padding: 0.4rem 0.7rem;
  }

  .footer-content {
    grid-template-columns: 1fr;
    text-align: center;
  }
}

@media (max-width: 400px) {
  #showcaseGrid.products-grid,
  .products-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.1rem;
  }

  .hero-content h1 {
    font-size: 1.5rem;
  }

  .page-hero h1 {
    font-size: 1.3rem;
  }

  .nav-right {
    gap: 0.3rem;
  }

  #cartToggle span:not(.badge) {
    display: none;
  }

  #showcaseGrid .product-card-image-wrapper {
    height: 150px;
  }

  #showcaseGrid .product-card-content {
    padding: 0.9rem 1rem 1rem;
  }

  .category-card {
    min-width: min(140px, 100%);
  }

  .category-tiles-container {
    padding: 0 38px;
  }

  .category-scroll-btn {
    width: 36px;
    height: 36px;
  }
}

/* ── Dealer dashboard: slide-out sidebar (was fully hidden <780px in Admin/styles) ── */
.dealer-sidebar-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 120;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.15));
  border-radius: 0.65rem;
  background: #ffffff;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.dealer-sidebar-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: #000000;
  border-radius: 1px;
}

.dealer-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(0, 0, 0, 0.35);
  border: none;
  padding: 0;
  margin: 0;
}

.dealer-layout.sidebar-open .dealer-sidebar-backdrop {
  display: block;
}

@media (max-width: 1024px) {
  .dealer-layout {
    grid-template-columns: 1fr !important;
    position: relative;
    padding-top: 3.25rem;
  }

  .dealer-sidebar-toggle {
    display: flex;
  }

  .dealer-layout .sidebar {
    display: flex !important;
    position: fixed !important;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(288px, 88vw);
    height: 100vh !important;
    max-height: none !important;
    z-index: 115;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    transform: translateX(-102%);
    transition: transform 0.25s ease;
    box-shadow: none;
    overflow-y: auto;
    border-right: 1px solid var(--border, rgba(0, 0, 0, 0.15));
    margin: 0;
    padding: 1.25rem !important;
  }

  .dealer-layout.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.12);
  }

  .dealer-layout main {
    padding: 1rem !important;
    min-width: 0;
  }

  .dealer-layout .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .dealer-layout .btn-group {
    width: 100%;
  }

  .dealer-layout .btn-group .btn {
    flex: 1;
    text-align: center;
    justify-content: center;
  }

  /* Orders / data tables */
  .dealer-layout .orders-grid,
  .dealer-layout .panel {
    max-width: 100%;
  }

  .dealer-layout .panel {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* product-view.php */
@media (max-width: 768px) {
  .detail-hero {
    grid-template-columns: 1fr;
    padding: 1.25rem;
  }

  .detail-hero img {
    max-width: 100%;
    max-height: 250px;
    margin: 0 auto;
  }

  #heroImageThumbnails {
    max-width: 100%;
  }

  main:has(.detail-hero) {
    padding: 2rem 1rem 1.5rem;
  }

  .detail-body {
    grid-template-columns: 1fr;
  }

  main:has(.detail-hero) .card {
    padding: 1rem;
  }
}

@media (max-width: 400px) {
  .detail-hero {
    padding: 1rem;
  }
}

/* about.php (inline-grid sections) */
@media (max-width: 768px) {
  section > div[style*="grid-template-columns: 1fr 1.5fr"],
  section > div[style*="grid-template-columns: 1.5fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  section > div[style*="height: 250px"] {
    height: 200px !important;
  }

  section > div[style*="display: grid"][style*="grid-template-columns"] > div:first-child[style*="padding: 2rem"] {
    order: 2;
  }

  section > div[style*="display: grid"][style*="grid-template-columns"] > div[style*="height: 250px"] {
    order: 1;
  }
}

/* cart.php */
@media (max-width: 768px) {
  .cart-item-card {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .cart-item-image {
    width: 100%;
    height: 200px;
    margin: 0 auto;
  }

  .cart-item-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .cart-item-quantity {
    justify-content: center;
  }
}

/* order-summary.php */
@media (max-width: 992px) {
  .order-content {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .sidebar-card {
    position: static;
  }
}

@media (max-width: 768px) {
  .summary-card {
    padding: 1.25rem;
  }

  .summary-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .order-actions {
    flex-direction: column;
  }

  .btn-primary-main {
    min-width: 100%;
  }
}

@media (max-width: 400px) {
  .page-hero {
    padding: 1rem;
  }
}
