/**
 * SupplyClub Product Filter - Frontend Styles
 *
 * Mobile-first responsive styles using CSS custom properties.
 * Target: < 5KB gzipped
 *
 * @package SupplyClub_Product_Filter
 * @since 1.0.0
 */

/* CSS Custom Properties */
:root {
    --scpf-primary: #2c3e50;
    --scpf-accent: #27ae60;
    --scpf-border: #e1e5e8;
    --scpf-background: #ffffff;
    --scpf-background-hover: #f8f9fa;
    --scpf-text: #333333;
    --scpf-text-muted: #718096;
    --scpf-radius: 4px;
    --scpf-transition: 200ms ease;
    --scpf-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Filter Container
   ========================================================================== */

.scpf-filters {
    font-size: 14px;
    line-height: 1.5;
    color: var(--scpf-text);
}

.scpf-filters--loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ==========================================================================
   Filter Group
   ========================================================================== */

.scpf-filter-group {
    border-bottom: 1px solid var(--scpf-border);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.scpf-filter-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.scpf-filter-group__header {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 8px 0;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    font-weight: 600;
    color: var(--scpf-primary);
}

.scpf-filter-group__header:hover {
    color: var(--scpf-accent);
}

.scpf-filter-group__toggle {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid currentColor;
    margin-right: 10px;
    transition: transform var(--scpf-transition);
}

.scpf-filter-group--collapsed .scpf-filter-group__toggle {
    transform: rotate(-90deg);
}

.scpf-filter-group__title {
    flex: 1;
}

.scpf-filter-group__count {
    color: var(--scpf-text-muted);
    font-weight: 400;
    font-size: 12px;
    margin-left: 8px;
}

.scpf-filter-group__options {
    padding-top: 8px;
}

.scpf-filter-group--collapsed .scpf-filter-group__options {
    display: none;
}

.scpf-filter-group__show-more {
    display: inline-block;
    margin-top: 8px;
    padding: 0;
    background: none;
    border: none;
    color: var(--scpf-accent);
    font-size: 13px;
    cursor: pointer;
    text-decoration: underline;
}

.scpf-filter-group__show-more:hover {
    text-decoration: none;
}

/* ==========================================================================
   Filter Option
   ========================================================================== */

.scpf-option {
    display: flex;
    align-items: center;
    padding: 6px 0;
    cursor: pointer;
    transition: background-color var(--scpf-transition);
}

.scpf-option:hover {
    background-color: var(--scpf-background-hover);
}

.scpf-option--hidden {
    display: none;
}

.scpf-option__checkbox {
    width: 16px;
    height: 16px;
    margin-right: 10px;
    accent-color: var(--scpf-accent);
    cursor: pointer;
}

.scpf-option__label {
    flex: 1;
    color: var(--scpf-text);
}

.scpf-option--active .scpf-option__label {
    font-weight: 500;
}

.scpf-option__count {
    color: var(--scpf-text-muted);
    font-size: 12px;
    margin-left: 8px;
}

/* ==========================================================================
   Category Tree (Hierarchical)
   ========================================================================== */

.scpf-category-tree {
    list-style: none;
    margin: 0;
    padding: 0;
}

.scpf-category-item {
    margin: 0;
    padding: 0;
}

.scpf-category-item__row {
    display: flex;
    align-items: center;
}

.scpf-category-toggle {
    width: 20px;
    height: 20px;
    padding: 0;
    margin-right: 4px;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
}

.scpf-category-toggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--scpf-text-muted);
    transform: translate(-50%, -50%) rotate(-90deg);
    transition: transform var(--scpf-transition);
}

.scpf-category-item--expanded .scpf-category-toggle::before {
    transform: translate(-50%, -50%) rotate(0);
}

.scpf-category-children {
    list-style: none;
    margin: 0;
    padding-left: 24px;
}

/* ==========================================================================
   Active Filters
   ========================================================================== */

.scpf-active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: var(--scpf-background-hover);
    border-radius: var(--scpf-radius);
}

.scpf-active-filters__count {
    font-size: 14px;
    font-weight: 500;
    color: var(--scpf-text);
    margin-right: auto;
}

.scpf-active-filters__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.scpf-active-filter {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--scpf-accent);
    color: #ffffff;
    border-radius: var(--scpf-radius);
    font-size: 12px;
    font-weight: 500;
}

.scpf-active-filter__label {
    margin-right: 6px;
}

.scpf-active-filter__remove {
    padding: 0;
    margin: 0;
    background: none;
    border: none;
    color: inherit;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.8;
}

.scpf-active-filter__remove:hover {
    opacity: 1;
}

.scpf-active-filters__clear {
    color: var(--scpf-text-muted);
    font-size: 13px;
    text-decoration: underline;
}

.scpf-active-filters__clear:hover {
    color: var(--scpf-text);
    text-decoration: none;
}

/* ==========================================================================
   Mobile Trigger Button
   ========================================================================== */

.scpf-mobile-trigger {
    position: fixed;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--scpf-accent);
    color: #ffffff;
    border: none;
    box-shadow: var(--scpf-shadow);
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--scpf-transition), box-shadow var(--scpf-transition);
}

.scpf-mobile-trigger--bottom-right {
    bottom: var(--scpf-offset, 20px);
    right: var(--scpf-offset, 20px);
}

.scpf-mobile-trigger--bottom-left {
    bottom: var(--scpf-offset, 20px);
    left: var(--scpf-offset, 20px);
}

.scpf-mobile-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.scpf-mobile-trigger__icon {
    display: flex;
}

.scpf-mobile-trigger__badge {
    position: absolute;
    top: 0;
    right: 0;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--scpf-primary);
    color: #ffffff;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
}

/* ==========================================================================
   Mobile Panel
   ========================================================================== */

.scpf-mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease, visibility 300ms ease;
}

.scpf-mobile-overlay--visible {
    opacity: 1;
    visibility: visible;
}

.scpf-mobile-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--scpf-panel-width, 85%);
    max-width: 400px;
    height: 100%;
    background: var(--scpf-background);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 300ms ease-out;
}

.scpf-mobile-panel--open {
    transform: translateX(0);
}

.scpf-mobile-panel__header {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--scpf-border);
    flex-shrink: 0;
}

.scpf-mobile-panel__close {
    width: 40px;
    height: 40px;
    padding: 0;
    margin-right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--scpf-text);
}

.scpf-mobile-panel__title {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    color: var(--scpf-primary);
}

.scpf-mobile-panel__count {
    font-size: 13px;
    color: var(--scpf-text-muted);
}

.scpf-mobile-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.scpf-mobile-panel__footer {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-top: 1px solid var(--scpf-border);
    flex-shrink: 0;
}

.scpf-mobile-panel__clear,
.scpf-mobile-panel__apply {
    flex: 1;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--scpf-radius);
    cursor: pointer;
    transition: background-color var(--scpf-transition);
}

.scpf-mobile-panel__clear {
    background: var(--scpf-background);
    border: 1px solid var(--scpf-border);
    color: var(--scpf-text);
}

.scpf-mobile-panel__clear:hover {
    background: var(--scpf-background-hover);
}

.scpf-mobile-panel__apply {
    background: var(--scpf-accent);
    border: none;
    color: #ffffff;
}

.scpf-mobile-panel__apply:hover {
    background: #219a52;
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.scpf-loading {
    position: relative;
}

.scpf-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes scpf-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.scpf-products-loading {
    animation: scpf-pulse 1.5s infinite;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Hide mobile trigger and panel on desktop */
@media (min-width: 768px) {
    .scpf-mobile-trigger,
    .scpf-mobile-panel,
    .scpf-mobile-overlay {
        display: none !important;
    }
}

/* Hide desktop sidebar on mobile - let CSS handle visibility */
@media (max-width: 767px) {
    /* Mobile-specific adjustments */
    .scpf-active-filters {
        flex-direction: column;
        align-items: flex-start;
    }

    .scpf-active-filters__count {
        margin-bottom: 8px;
        margin-right: 0;
    }
}
