/* ══════════════════════════════════════════════
   MOBILE UI/UX - Responsive Overrides
   ══════════════════════════════════════════════
   This file is loaded AFTER all other CSS.
   On desktop (>768px) everything here is hidden.
   On mobile (<=768px) mobile-specific components
   replace the desktop navbar with a bottom nav
   + slide-out drawer pattern.
   ══════════════════════════════════════════════ */

/* Alpine.js x-cloak - hide until initialized */
[x-cloak] { display: none !important; }

/* ── DESKTOP DEFAULTS (hidden on mobile) ──── */
.m-bottom-nav,
.m-drawer-overlay,
.m-mobile-top-bar,
.m-filter-fab {
  display: none !important;
}

/* ══════════════════════════════════════════════
   MOBILE BREAKPOINT: <=768px
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── MOBILE TOP BAR ─────────────────────────── */
  .m-mobile-top-bar {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 998;
    background: var(--white, #fff);
    border-bottom: 1px solid var(--border, #e8e4df);
    padding: 8px 14px;
    gap: 10px;
    min-height: 52px;
  }

  .m-mobile-top-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .m-mobile-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
  }

  .m-mobile-hamburger:active {
    background: rgba(0,0,0,0.06);
  }

  .m-mobile-hamburger svg {
    width: 22px;
    height: 22px;
    stroke: var(--dark, #1a1a1a);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .m-mobile-search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
  }

  .m-mobile-search-toggle:active {
    background: rgba(0,0,0,0.06);
  }

  .m-mobile-search-toggle svg {
    width: 20px;
    height: 20px;
    stroke: var(--dark, #1a1a1a);
    fill: none;
    stroke-width: 2;
  }

  .m-mobile-logo img {
    height: 32px;
    width: auto;
  }

  .m-mobile-top-bar-right {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .m-mobile-icon-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
  }

  .m-mobile-icon-btn:active {
    background: rgba(0,0,0,0.06);
  }

  .m-mobile-icon-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--dark, #1a1a1a);
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .m-mobile-icon-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--orange, #F26522);
    color: #fff;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    font-family: 'Cairo', sans-serif;
    pointer-events: none;
  }

  /* ── MOBILE SEARCH BAR (expandable) ────────── */
  .m-mobile-search-bar {
    display: none;
    position: sticky;
    top: 52px;
    z-index: 997;
    background: var(--white, #fff);
    border-bottom: 1px solid var(--border, #e8e4df);
    padding: 10px 14px;
  }

  .m-mobile-search-bar.is-open {
    display: block;
  }

  .m-mobile-search-bar form {
    width: 100%;
  }

  .m-mobile-search-bar input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1px solid var(--border, #e8e4df);
    border-radius: 12px;
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    background: var(--light-gray, #f7f7f7);
    outline: none;
    color: var(--dark, #1a1a1a);
    direction: rtl;
    -webkit-appearance: none;
  }

  .m-mobile-search-bar input:focus {
    border-color: var(--orange, #F26522);
    box-shadow: 0 0 0 3px rgba(242, 101, 34, 0.1);
  }

  .m-mobile-search-bar .m-search-icon {
    position: absolute;
    right: 26px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    stroke: #999;
    fill: none;
    stroke-width: 2;
    pointer-events: none;
  }

  /* ── HIDE DESKTOP NAVBAR ON MOBILE ─────────── */
  .navbar,
  .nav-inner {
    display: none !important;
  }

  /* ── BODY PADDING FOR FIXED BOTTOM NAV ─────── */
  body {
    padding-bottom: 68px !important;
  }

  /* ── MOBILE BOTTOM NAVIGATION ───────────────── */
  .m-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--white, #fff);
    border-top: 1px solid var(--border, #e8e4df);
    padding: 4px 0;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
    align-items: stretch;
    justify-content: space-around;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    height: 64px;
    direction: ltr;
  }

  .m-bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    text-decoration: none;
    color: #999;
    font-size: 10px;
    font-weight: 600;
    font-family: 'Cairo', sans-serif;
    padding: 4px 2px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
    position: relative;
    min-height: 44px;
  }

  .m-bottom-nav-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.15s;
  }

  .m-bottom-nav-item:active svg {
    transform: scale(0.9);
  }

  .m-bottom-nav-item.is-active {
    color: var(--orange, #F26522);
  }

  .m-bottom-nav-item.is-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--orange, #F26522);
    border-radius: 0 0 4px 4px;
  }

  .m-bottom-nav-badge {
    position: absolute;
    top: 2px;
    right: 50%;
    transform: translateX(calc(50% + 8px));
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--orange, #F26522);
    color: #fff;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    pointer-events: none;
  }

/* ── MOBILE DRAWER ──────────────────────────── */
  .m-drawer-overlay {
    display: block !important;
    position: fixed;
    inset: 0;
    z-index: 1001;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }

  .m-drawer-overlay.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .m-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }

  .m-drawer-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(85vw, 340px);
    max-width: 340px;
    background: var(--white, #fff);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .m-drawer-overlay.is-open .m-drawer-panel {
    transform: translateX(0);
  }

  [dir="ltr"] .m-drawer-panel {
    right: auto;
    left: 0;
    transform: translateX(-100%);
  }

  [dir="ltr"] .m-drawer-overlay.is-open .m-drawer-panel {
    transform: translateX(0);
  }

  .m-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, #e8e4df);
    flex-shrink: 0;
  }

  .m-drawer-logo img {
    height: 32px;
    width: auto;
  }

  .m-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s;
  }

  .m-drawer-close:active {
    background: rgba(0,0,0,0.06);
  }

  .m-drawer-close svg {
    width: 20px;
    height: 20px;
    stroke: var(--dark, #1a1a1a);
    fill: none;
    stroke-width: 2;
  }

  /* User Info */
  .m-drawer-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border, #e8e4df);
  }

  .m-drawer-user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--orange, #F26522), #FF8C42);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .m-drawer-user-avatar svg {
    width: 24px;
    height: 24px;
    stroke: #fff;
    fill: none;
    stroke-width: 1.5;
  }

  .m-drawer-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .m-drawer-user-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--dark, #1a1a1a);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .m-drawer-user-email {
    font-size: 12px;
    color: #999;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Search in drawer */
  .m-drawer-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, #e8e4df);
  }

  /* Navigation links */
  .m-drawer-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
  }

  .m-drawer-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 20px;
    text-decoration: none;
    color: var(--dark, #1a1a1a);
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.12s, color 0.12s;
    -webkit-tap-highlight-color: transparent;
    min-height: 48px;
  }

  .m-drawer-link:active {
    background: rgba(0, 0, 0, 0.04);
  }

  .m-drawer-link svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
  }

  .m-drawer-link.is-active {
    color: var(--orange, #F26522);
    background: rgba(242, 101, 34, 0.06);
  }

  .m-drawer-divider {
    height: 1px;
    background: var(--border, #e8e4df);
    margin: 6px 16px;
  }

  .m-drawer-logout {
    color: #dc3545;
  }

  .m-drawer-logout:active {
    background: rgba(220, 53, 69, 0.06);
  }

  /* Language switcher in drawer */
  .m-drawer-lang {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
  }

  .m-drawer-lang-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border: 1.5px solid var(--border, #e8e4df);
    border-radius: 10px;
    background: transparent;
    font-family: 'Cairo', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark, #1a1a1a);
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
  }

  .m-drawer-lang-btn:active {
    transform: scale(0.97);
  }

  .m-drawer-lang-btn.is-active {
    border-color: var(--orange, #F26522);
    background: rgba(242, 101, 34, 0.06);
    color: var(--orange, #F26522);
  }

  .m-drawer-lang-flag {
    font-size: 16px;
  }

  /* ── MOBILE FILTER FAB (Products page) ────── */
  .m-filter-fab {
    display: flex !important;
    position: fixed;
    bottom: calc(64px + env(safe-area-inset-bottom) + 16px);
    left: 16px;
    z-index: 1001;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--orange, #F26522);
    color: #fff;
    border: none;
    border-radius: 999px;
    font-family: 'Cairo', sans-serif;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(242, 101, 34, 0.35);
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s, box-shadow 0.15s;
  }

  .m-filter-fab:active {
    transform: scale(0.95);
  }

  .m-filter-fab svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
  }

  [dir="ltr"] .m-filter-fab {
    left: auto;
    right: 16px;
  }

  /* ── MOBILE FILTER BOTTOM SHEET ─────────── */
  .m-filter-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1003;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }

  .m-filter-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 80vh;
    background: var(--white, #fff);
    border-radius: 20px 20px 0 0;
    z-index: 1004;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.12);
  }

  .m-filter-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border, #e8e4df);
    position: sticky;
    top: 0;
    background: var(--white, #fff);
    z-index: 1;
  }

  .m-filter-sheet-header h3 {
    font-size: 16px;
    font-weight: 800;
    color: var(--dark, #1a1a1a);
    margin: 0;
  }

  .m-filter-sheet-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
  }

  .m-filter-sheet-close:active {
    background: rgba(0,0,0,0.06);
  }

  .m-filter-sheet-close svg {
    width: 20px;
    height: 20px;
    stroke: var(--dark, #1a1a1a);
    fill: none;
    stroke-width: 2;
  }

  .m-filter-sheet-body {
    padding: 16px 20px 24px;
  }

  .m-filter-sheet-body .sidebar-section {
    margin-bottom: 20px;
  }

  .m-filter-sheet-body .filter-item {
    min-height: 44px;
  }

  .m-filter-sheet-body .filter-tab {
    width: 100%;
    text-align: center;
    padding: 12px;
    font-size: 14px;
    margin-top: 8px;
  }

  /* ── MOBILE PAGE CONTENT ADJUSTMENTS ──────── */

  /* Categories page */
  .catalog-browser-page {
    padding-top: 16px !important;
  }

  .catalog-toolbar {
    flex-direction: column;
    gap: 12px;
    padding: 14px;
  }

  .catalog-toggle {
    width: 100%;
  }

  .catalog-toggle-btn {
    flex: 1;
    text-align: center;
    padding: 10px 12px;
    font-size: 12px;
  }

  .catalog-search-wrap,
  .catalog-search {
    width: 100%;
  }

  .catalog-results-title {
    font-size: 20px;
  }

  .catalog-card {
    min-height: auto;
    border-radius: 18px;
  }

  .catalog-card-body {
    padding: 14px;
  }

  .catalog-card-title {
    font-size: 18px;
  }

  /* Products page */
  .hero-section {
    padding: 20px 0 28px !important;
  }

  .container {
    padding: 0 14px !important;
  }

  .shop-section {
    padding: 20px 0 40px !important;
  }

  .shop-layout {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  /* Hide sidebar on mobile, show as bottom sheet */
  .sidebar {
    display: none !important;
  }

  .products-topbar {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .prod-card {
    border-radius: 12px;
  }

  .prod-body {
    padding: 8px 10px 10px;
  }

  .prod-name {
    font-size: 12px;
  }

  .prod-price-new {
    font-size: 13px;
  }

  .sort-btn {
    min-width: auto;
    padding: 6px 10px;
    font-size: 12px;
  }

  /* Home page */
  .categories {
    padding: 32px 14px !important;
  }

  .category-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .bestsellers {
    padding: 32px 14px !important;
  }

  .products-grid,
  .products-grid-2 {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .featured-strips {
    padding: 32px 14px !important;
  }

  .strips-grid {
    gap: 14px !important;
  }

  .news {
    padding: 32px 14px 60px !important;
  }

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

  .hero {
    padding: 40px 18px !important;
    min-height: 320px !important;
  }

  .hero h1 {
    font-size: 24px !important;
  }

  .hero p {
    font-size: 13px !important;
  }

  .hero-btns {
    flex-direction: column;
    gap: 10px;
  }

  .cta-section {
    padding: 40px 14px !important;
  }

  .cta-box {
    padding: 32px 20px !important;
    border-radius: 18px;
  }

  .cta-box h2 {
    font-size: 22px !important;
  }

  .cta-btns {
    flex-direction: column;
    gap: 10px !important;
  }

  .filter-tabs {
    gap: 6px;
    margin-bottom: 20px;
  }

  .filter-tab {
    padding: 6px 14px;
    font-size: 12px;
  }

  /* Footer mobile */
  .footer-section {
    padding: 40px 14px 16px !important;
  }

  .footer-top {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .store-btns {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Notification dropdown mobile override */
  [style*="width:440px"] {
    width: calc(100vw - 24px) !important;
    right: -8px !important;
    left: auto !important;
    max-width: 360px;
  }

  /* Welcome page hero cards */
  .hero-cards {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    padding: 0 14px !important;
  }

  .hero-card {
    padding: 12px !important;
  }

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

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

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

/* ══════════════════════════════════════════════
   SMALL MOBILE: <=480px
   ══════════════════════════════════════════════ */
@media (max-width: 480px) {
  .m-bottom-nav {
    height: 60px;
  }

  .m-bottom-nav-item {
    font-size: 9px;
    gap: 1px;
  }

  .m-bottom-nav-item svg {
    width: 20px;
    height: 20px;
  }

  .m-drawer-panel {
    width: 90vw;
  }

  .products-grid {
    gap: 8px !important;
  }

  .prod-img-wrap {
    aspect-ratio: 1;
  }

  .catalog-grid {
    gap: 12px !important;
  }

  .category-grid {
    gap: 8px !important;
  }
}

/* ══════════════════════════════════════════════
   TRANSITION HELPERS
   ══════════════════════════════════════════════ */
.transition.ease-out.duration-300 {
  transition-property: opacity, transform;
  transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
  transition-duration: 300ms;
}

.transition.ease-in.duration-200 {
  transition-property: opacity, transform;
  transition-timing-function: cubic-bezier(0.4, 0, 1, 1);
  transition-duration: 200ms;
}

.opacity-0 { opacity: 0; }
.opacity-100 { opacity: 1; }
