/* Mobile category sheet — slides up above bottom nav */
@media (max-width: 1100px) {
  .mobile-catalog-backdrop {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    bottom: var(--mobile-nav-offset, calc(var(--mobile-nav-height, 3.5625rem) + env(safe-area-inset-bottom, 0px)));
    z-index: 1050;
    background: rgba(15, 23, 42, 0.55);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
    clip-path: inset(0 0 var(--mobile-nav-offset, calc(var(--mobile-nav-height, 3.5625rem) + env(safe-area-inset-bottom, 0px))) 0);
  }

  .mobile-catalog-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-catalog-backdrop[hidden],
  .mobile-catalog-sheet[hidden] {
    display: none !important;
  }

  .mobile-catalog-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: var(--mobile-nav-offset, calc(var(--mobile-nav-height, 3.5625rem) + env(safe-area-inset-bottom, 0px)));
    z-index: 1055;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--mobile-nav-offset, calc(var(--mobile-nav-height, 3.5625rem) + env(safe-area-inset-bottom, 0px))));
    max-height: calc(100vh - var(--mobile-nav-offset, calc(var(--mobile-nav-height, 3.5625rem) + env(safe-area-inset-bottom, 0px))));
    background: #fff;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.16);
    transform: translate3d(0, calc(100% + var(--mobile-nav-offset, calc(var(--mobile-nav-height, 3.5625rem) + env(safe-area-inset-bottom, 0px)))), 0);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.32s;
    overflow: hidden;
    will-change: transform;
    visibility: hidden;
    pointer-events: none;
  }

  .mobile-catalog-sheet.is-open {
    transform: translate3d(0, 0, 0);
    visibility: visible;
    pointer-events: auto;
  }

  .mobile-catalog-sheet.is-dragging {
    transition: none;
  }

  .mobile-catalog-grabber {
    flex-shrink: 0;
    width: 2.75rem;
    height: 0.28rem;
    margin: 0.4rem auto 0.1rem;
    border-radius: 999px;
    background: #d1d5db;
    touch-action: none;
  }

  .mobile-catalog-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0.25rem 1rem 0.5rem;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
  }

  .mobile-catalog-title {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.92rem;
    font-weight: 800;
    color: var(--text);
  }

  .mobile-catalog-title .bi {
    color: var(--primary);
    font-size: 1rem;
  }

  .mobile-catalog-close {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 10px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
  }

  .mobile-catalog-tabs {
    flex-shrink: 0;
    display: flex;
    gap: 0;
    padding: 0 1rem;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
  }

  .mobile-catalog-tab {
    flex: 1;
    padding: 0.55rem 0.5rem;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    color: #94a3b8;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.15s ease, border-color 0.15s ease;
  }

  .mobile-catalog-tab.is-active {
    color: var(--primary);
    border-bottom-color: var(--primary);
  }

  .mobile-catalog-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: #fff;
  }

  .mobile-catalog-panel {
    display: none;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: #fff;
  }

  .mobile-catalog-panel.is-active {
    display: flex;
  }

  .mobile-catalog-panel[hidden] {
    display: none !important;
  }

  .mobile-catalog-split {
    display: flex;
    flex: 1;
    min-height: 0;
    background: #fff;
    overflow: hidden;
  }

  /* ریل دسته‌های اصلی — سمت راست در RTL */
  .mobile-catalog-rail {
    flex-shrink: 0;
    width: 32%;
    max-width: 120px;
    min-width: 96px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 6px 5px 10px;
    background: #f1f5f9;
    border-left: 1px solid #e2e8f0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-catalog-rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    padding: 9px 5px 10px;
    margin: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    font-family: inherit;
    cursor: pointer;
    color: #64748b;
    transition: background 0.15s ease, color 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-catalog-rail-item.is-active {
    background: #fff;
    color: var(--primary);
    box-shadow: none;
    position: relative;
  }

  .mobile-catalog-rail-item.is-active::after {
    content: '';
    position: absolute;
    left: -5px;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--primary);
  }

  .mobile-catalog-rail-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    font-size: 1.22rem;
    line-height: 1;
  }

  .mobile-catalog-rail-label {
    font-size: 0.68rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .mobile-catalog-panes {
    flex: 1;
    min-width: 0;
    min-height: 0;
    background: #fff;
    overflow: hidden;
  }

  .mobile-catalog-pane {
    display: none;
    height: 100%;
    min-height: 0;
    padding: 6px 10px 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
  }

  .mobile-catalog-pane.is-active {
    display: block;
  }

  .mobile-catalog-pane-all {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 10px;
    background: rgba(30, 86, 160, 0.06);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
  }

  .mobile-catalog-links,
  .mobile-catalog-quick-list {
    list-style: none;
    margin: 0;
    padding: 0;
  }

  .mobile-catalog-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px 4px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.15s ease;
  }

  .mobile-catalog-link:last-child {
    border-bottom: none;
  }

  .mobile-catalog-link span {
    flex: 1;
    min-width: 0;
    line-height: 1.35;
  }

  .mobile-catalog-link .bi {
    flex-shrink: 0;
    font-size: 0.72rem;
    color: #cbd5e1;
  }

  .mobile-catalog-link:hover,
  .mobile-catalog-link.is-active {
    color: var(--primary);
  }

  .mobile-catalog-link:hover .bi,
  .mobile-catalog-link.is-active .bi {
    color: var(--primary);
  }

  .mobile-catalog-quick-list {
    height: 100%;
    padding: 6px 12px 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
  }

  .mobile-catalog-empty {
    padding: 20px 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.86rem;
  }

  body.mobile-catalog-open {
    overflow: hidden;
  }
}

@media (min-width: 1101px) {
  .mobile-catalog-backdrop,
  .mobile-catalog-sheet {
    display: none !important;
  }
}

@media (max-width: 380px) {
  .mobile-catalog-rail-label {
    font-size: 0.64rem;
  }

  .mobile-catalog-rail-icon {
    width: 34px;
    height: 34px;
    font-size: 1.1rem;
  }

  .mobile-catalog-link {
    font-size: 0.86rem;
    padding: 11px 2px;
  }
}
