/**
 * Catalog Mobile Styles
 * Mobile filter/sort panels, mobile product cards
 * Upgraded: premium app-like feel, smoother animations
 */

/* ============================================================================
   MOBILE FILTER/SORT BUTTON BAR
   Less boxy, cleaner design
   ============================================================================ */

.mobile-filter-bar {
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: clamp(0.75rem, 2vw, 1rem) 0;
    background-color: transparent;
    border: none;
    border-radius: 0;
    margin-bottom: clamp(1rem, 2vw, 1.25rem);
}

/* Mobile search inline - directly visible in filter bar */
.mobile-search-inline {
    width: 100%;
}

.mobile-search-inline .filter-search {
    width: 100%;
    padding: clamp(0.75rem, 2vw, 0.875rem) clamp(1rem, 2.5vw, 1.25rem);
    background-color: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: 50px;
    color: var(--text-primary);
    font-size: 0.875rem;
    min-height: 48px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-search-inline .filter-search:focus {
    outline: none;
    border-color: var(--accent);
    background-color: var(--bg-tertiary);
}

.mobile-search-inline .filter-search::placeholder {
    color: var(--text-muted);
}

.mobile-search-inline .filter-search:disabled {
    opacity: 1;
    cursor: default;
    color: var(--text-muted);
}

/* Button container for Filter and Sort buttons */
.mobile-filter-bar__buttons {
    display: flex;
    gap: 10px;
    width: 100%;
}

/* Pill-shaped buttons with subtle styling */
.mobile-filter-btn,
.mobile-sort-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: clamp(0.75rem, 2vw, 0.875rem) clamp(1rem, 2.5vw, 1.25rem);
    background-color: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: 50px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 48px; /* Touch target */
}

.mobile-filter-btn:hover,
.mobile-sort-btn:hover {
    background-color: var(--bg-tertiary);
}

.mobile-filter-btn:active,
.mobile-sort-btn:active {
    transform: scale(0.98);
}

.mobile-filter-btn svg,
.mobile-sort-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.mobile-filter-btn .filter-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    background-color: var(--accent);
    color: #000;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 11px;
    margin-left: 4px;
    box-shadow: 0 2px 6px rgba(var(--accent-rgb), 0.3);
}

/* ============================================================================
   MOBILE FILTER PANEL OVERLAY
   ============================================================================ */

.mobile-filter-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.mobile-filter-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================================================
   MOBILE FILTER PANEL (SLIDE-UP)
   Premium app-like design with larger radius and better shadows
   ============================================================================ */

.mobile-filter-panel {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 90vh;
    background-color: var(--bg-primary);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    pointer-events: none;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);
}

.mobile-filter-panel.is-active {
    transform: translateY(0);
    pointer-events: auto;
}

/* Drag handle indicator */
.mobile-filter-panel::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background-color: var(--border);
    border-radius: 2px;
    z-index: 2;
}

.mobile-filter-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: clamp(1.25rem, 3vw, 1.5rem) clamp(1.25rem, 3vw, 1.5rem) clamp(1rem, 2vw, 1.25rem);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background-color: var(--bg-primary);
    z-index: 1;
}

/* Bolder title */
.mobile-filter-panel__title {
    font-size: clamp(1.125rem, 2.5vw, 1.25rem);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.mobile-filter-panel__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.mobile-filter-panel__close:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.mobile-filter-panel__close:active {
    transform: scale(0.95);
}

.mobile-filter-panel__close svg {
    width: 20px;
    height: 20px;
}

.mobile-filter-panel__content {
    padding: clamp(1.25rem, 3vw, 1.5rem);
    overflow-y: auto;
    max-height: calc(90vh - 160px);
    -webkit-overflow-scrolling: touch;
}

/* Filter groups in mobile panel */
.mobile-filter-panel__content .filter-group {
    margin-bottom: clamp(1.25rem, 3vw, 1.5rem);
    padding-bottom: clamp(1.25rem, 3vw, 1.5rem);
    border-bottom: 1px solid var(--border);
}

.mobile-filter-panel__content .filter-group:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* Larger touch targets for checkboxes on mobile */
.mobile-filter-panel__content .filter-checkbox {
    padding: clamp(0.75rem, 2vw, 0.875rem) clamp(0.5rem, 1.5vw, 0.75rem);
    min-height: 52px;
}

.mobile-filter-panel__content .filter-checkbox input[type="checkbox"] {
    width: 22px;
    height: 22px;
}

.mobile-filter-panel__footer {
    display: flex;
    gap: 12px;
    padding: clamp(1rem, 2.5vw, 1.25rem) clamp(1.25rem, 3vw, 1.5rem);
    border-top: 1px solid var(--border);
    background-color: var(--bg-primary);
    position: sticky;
    bottom: 0;
}

.mobile-filter-reset {
    flex: 1;
    padding: clamp(0.875rem, 2vw, 1rem) clamp(1rem, 2.5vw, 1.25rem);
    background: transparent;
    border: 2px solid var(--border);
    border-radius: 14px;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 52px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-filter-reset:hover {
    border-color: var(--error);
    color: var(--error);
    background-color: var(--error-bg, rgba(239, 68, 68, 0.05));
}

.mobile-filter-reset:active {
    transform: scale(0.98);
}

/* Full accent button, prominent */
.mobile-filter-apply {
    flex: 2;
    padding: clamp(0.875rem, 2vw, 1rem) clamp(1rem, 2.5vw, 1.25rem);
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
    border: none;
    border-radius: 14px;
    color: #000;
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    min-height: 52px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.3);
}

.mobile-filter-apply:hover {
    box-shadow: 0 6px 20px rgba(var(--accent-rgb), 0.4);
    transform: translateY(-1px);
}

.mobile-filter-apply:active {
    transform: scale(0.98) translateY(0);
    box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.3);
}

/* ============================================================================
   MOBILE SORT PANEL
   Premium styling matching filter panel
   ============================================================================ */

.mobile-sort-panel {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-primary);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    pointer-events: none;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.15);
}

.mobile-sort-panel.is-active {
    transform: translateY(0);
    pointer-events: auto;
}

/* Drag handle indicator */
.mobile-sort-panel::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background-color: var(--border);
    border-radius: 2px;
    z-index: 2;
}

.mobile-sort-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: clamp(1.25rem, 3vw, 1.5rem) clamp(1.25rem, 3vw, 1.5rem) clamp(1rem, 2vw, 1.25rem);
    border-bottom: 1px solid var(--border);
}

.mobile-sort-panel__title {
    font-size: clamp(1.125rem, 2.5vw, 1.25rem);
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.mobile-sort-panel__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.mobile-sort-panel__close:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.mobile-sort-panel__close:active {
    transform: scale(0.95);
}

.mobile-sort-panel__options {
    padding: clamp(0.5rem, 1.5vw, 0.75rem) 0;
}

/* Better active state with accent color */
.mobile-sort-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: clamp(0.875rem, 2vw, 1rem) clamp(1.25rem, 3vw, 1.5rem);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    text-align: left;
    cursor: pointer;
    min-height: 52px;
    transition: all 0.2s ease;
    position: relative;
}

.mobile-sort-option:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.mobile-sort-option:active {
    background-color: var(--bg-tertiary);
}

.mobile-sort-option.is-active {
    color: var(--accent);
    font-weight: 600;
    background-color: var(--accent-light);
}

.mobile-sort-option.is-active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background-color: var(--accent);
    border-radius: 0 2px 2px 0;
}

.mobile-sort-option.is-active::after {
    content: '';
    display: block;
    width: 22px;
    height: 22px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%234a9fd4' stroke-width='2.5'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    flex-shrink: 0;
}

/* ============================================================================
   MOBILE PRODUCT CARDS
   ============================================================================ */

.mobile-product-list {
    display: none;
    flex-direction: column;
    gap: clamp(0.75rem, 2vw, 1rem);
}

.mobile-product-card {
    display: flex;
    flex-direction: column;
    background-color: var(--bg-secondary);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid transparent;
    transition: all 0.2s ease;
    overflow: hidden;
}

.mobile-product-card:active {
    background-color: var(--bg-tertiary);
    transform: scale(0.99);
    box-shadow: var(--shadow-md);
}

/* SEO-friendly link wrapper for mobile card content */
.mobile-product-card__link {
    display: flex;
    gap: clamp(0.75rem, 2vw, 1rem);
    padding: clamp(0.75rem, 2vw, 1rem);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.mobile-product-card__image {
    flex-shrink: 0;
    width: clamp(72px, 20vw, 88px);
    height: clamp(72px, 20vw, 88px);
    background-color: var(--bg-tertiary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
}

.mobile-product-card__image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.2s ease;
}

.mobile-product-card:active .mobile-product-card__image img {
    transform: scale(1.03);
}

.mobile-product-card__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
}

.mobile-product-card__brand {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 500;
}

.mobile-product-card__name {
    font-size: clamp(0.875rem, 2.5vw, 0.9375rem);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.35;
}

.mobile-product-card__specs {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.mobile-product-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 clamp(0.75rem, 2vw, 1rem) clamp(0.75rem, 2vw, 1rem);
    gap: 8px;
}

.mobile-product-card__price {
    font-size: clamp(1rem, 3vw, 1.125rem);
    font-weight: 700;
    color: var(--accent);
}

.mobile-product-card__add {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: var(--accent);
    color: #000;
    font-size: 1.25rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.25);
}

.mobile-product-card__add:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.35);
}

.mobile-product-card__add:active {
    transform: scale(0.95);
}

/* ============================================================================
   MOBILE - UNAVAILABLE PRODUCT STYLING
   ============================================================================ */

.mobile-product-card__price--unavailable {
    color: var(--text-muted);
    font-weight: 600;
}

.mobile-product-card__stock {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--warning);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mobile-product-card__stock--unavailable {
    color: var(--error);
}

/* ============================================================================
   MOBILE - LOADING STATE
   ============================================================================ */

.mobile-product-list.is-loading {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* ============================================================================
   BODY SCROLL LOCK
   ============================================================================ */

/* Prevent body scroll when panel is open */
body.mobile-panel-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ============================================================================
   SAFE AREA FOR NOTCHED DEVICES
   ============================================================================ */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .mobile-filter-panel__footer {
        padding-bottom: calc(clamp(1rem, 2.5vw, 1.25rem) + env(safe-area-inset-bottom));
    }

    .mobile-sort-panel {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .mobile-sort-panel__options {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* ============================================================================
   REDUCED MOTION SUPPORT
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
    .mobile-filter-btn,
    .mobile-sort-btn,
    .mobile-filter-panel,
    .mobile-sort-panel,
    .mobile-filter-overlay,
    .mobile-filter-apply,
    .mobile-filter-reset,
    .mobile-product-card,
    .mobile-product-card__image img,
    .mobile-product-card__add,
    .mobile-filter-panel__close,
    .mobile-sort-panel__close,
    .mobile-sort-option {
        transition: none;
    }

    .mobile-filter-btn:active,
    .mobile-sort-btn:active,
    .mobile-filter-apply:active,
    .mobile-filter-apply:hover,
    .mobile-filter-reset:active,
    .mobile-product-card:active,
    .mobile-product-card:active .mobile-product-card__image img,
    .mobile-product-card__add:active,
    .mobile-filter-panel__close:active,
    .mobile-sort-panel__close:active {
        transform: none;
    }
}

/* ============================================================================
   SSR DISABLED STATES
   Make disabled elements look IDENTICAL to enabled ones
   ============================================================================ */

/* SSR Mobile Filter Bar - same as JS version */
.mobile-filter-bar--ssr {
    /* Inherits base mobile-filter-bar styles */
}

.mobile-filter-bar--ssr .mobile-filter-btn,
.mobile-filter-bar--ssr .mobile-sort-btn,
.mobile-filter-bar--ssr .mobile-filter-btn:disabled,
.mobile-filter-bar--ssr .mobile-sort-btn:disabled {
    opacity: 1;
    cursor: default;
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.mobile-filter-bar--ssr .mobile-filter-btn:hover,
.mobile-filter-bar--ssr .mobile-sort-btn:hover {
    background: var(--bg-secondary);
    transform: none;
}

.mobile-filter-bar--ssr .mobile-filter-btn svg,
.mobile-filter-bar--ssr .mobile-sort-btn svg,
.mobile-filter-bar--ssr .mobile-filter-btn:disabled svg,
.mobile-filter-bar--ssr .mobile-sort-btn:disabled svg {
    color: inherit;
    opacity: 0.7;
}
