/**
 * Hello Vloer Filter Styles
 *
 * Styles for the product filter sidebar component.
 * Uses CSS custom properties for easy theming.
 *
 * @package HelloVloer
 * @since 1.0.0
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

.hv-filter-sidebar {
    --hv-filter-primary: #FFE500;
    --hv-filter-text: #1a1a1a;
    --hv-filter-text-muted: #6b7280;
    --hv-filter-border: #e5e7eb;
    --hv-filter-bg: #ffffff;
    --hv-filter-bg-hover: #f9fafb;
    --hv-filter-radius: 0.375rem;
    --hv-filter-spacing: 1rem;
    --hv-filter-transition: 150ms ease;
}

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

.hv-filter-sidebar {
    position: relative;
    background-color: var(--hv-filter-bg);
    border-radius: var(--hv-filter-radius);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* ==========================================================================
   Filter Header
   ========================================================================== */

.hv-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--hv-filter-spacing);
    border-bottom: 1px solid var(--hv-filter-border);
}

.hv-filter-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--hv-filter-text);
    margin: 0;
}

.hv-filter-reset {
    font-size: 0.75rem;
    color: var(--hv-filter-text-muted);
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: color var(--hv-filter-transition);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.hv-filter-reset:hover,
.hv-filter-reset:focus {
    color: var(--hv-filter-text);
}

/* ==========================================================================
   Filter Form
   ========================================================================== */

.hv-filter-form {
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   Filter Groups (Collapsible sections)
   ========================================================================== */

.hv-filter-group {
    border-bottom: 1px solid var(--hv-filter-border);
}

.hv-filter-group:last-child {
    border-bottom: none;
}

.hv-filter-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--hv-filter-spacing);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background-color var(--hv-filter-transition);
}

.hv-filter-group-header:hover {
    background-color: var(--hv-filter-bg-hover);
}

.hv-filter-group-header:focus {
    outline: 2px solid var(--hv-filter-primary);
    outline-offset: -2px;
}

.hv-filter-group-title {
    font-weight: 500;
    color: var(--hv-filter-text);
    flex: 1;
}

.hv-filter-group-active-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    margin-right: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--hv-filter-text);
    background-color: var(--hv-filter-primary);
    border-radius: 9999px;
}

.hv-filter-group-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    color: var(--hv-filter-text-muted);
    transition: transform var(--hv-filter-transition);
}

.hv-filter-group-toggle.is-open {
    transform: rotate(180deg);
}

.hv-filter-group-toggle svg {
    width: 1rem;
    height: 1rem;
}

.hv-filter-group-content {
    padding: 0 var(--hv-filter-spacing) var(--hv-filter-spacing);
    overflow: hidden;
}

/* Collapse transition classes (Alpine.js x-transition) */
.hv-collapse-enter {
    transition: opacity 200ms ease-out, max-height 200ms ease-out;
}

.hv-collapse-enter-start {
    opacity: 0;
    max-height: 0;
}

.hv-collapse-enter-end {
    opacity: 1;
    max-height: 500px;
}

.hv-collapse-leave {
    transition: opacity 150ms ease-in, max-height 150ms ease-in;
}

.hv-collapse-leave-start {
    opacity: 1;
    max-height: 500px;
}

.hv-collapse-leave-end {
    opacity: 0;
    max-height: 0;
}

/* ==========================================================================
   Filter Options (Checkboxes & Radios)
   ========================================================================== */

.hv-filter-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.hv-filter-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
    cursor: pointer;
    transition: opacity var(--hv-filter-transition);
}

.hv-filter-option.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.hv-filter-option input[type="checkbox"],
.hv-filter-option input[type="radio"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.hv-filter-option-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.125rem;
    height: 1.125rem;
    border: 2px solid var(--hv-filter-border);
    border-radius: 0.25rem;
    background-color: var(--hv-filter-bg);
    transition: all var(--hv-filter-transition);
    flex-shrink: 0;
}

/* Radio style */
.hv-filter-option input[type="radio"] + .hv-filter-option-checkbox {
    border-radius: 50%;
}

/* Checked state */
.hv-filter-option input:checked + .hv-filter-option-checkbox {
    background-color: var(--hv-filter-primary);
    border-color: var(--hv-filter-primary);
}

.hv-filter-option input:checked + .hv-filter-option-checkbox::after {
    content: '';
    display: block;
    width: 0.5rem;
    height: 0.5rem;
    background-color: var(--hv-filter-text);
}

/* Checkbox checkmark */
.hv-filter-option input[type="checkbox"]:checked + .hv-filter-option-checkbox::after {
    width: 0.375rem;
    height: 0.625rem;
    background: none;
    border: 2px solid var(--hv-filter-text);
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translateY(-1px);
}

/* Radio dot */
.hv-filter-option input[type="radio"]:checked + .hv-filter-option-checkbox::after {
    border-radius: 50%;
}

/* Focus state */
.hv-filter-option input:focus + .hv-filter-option-checkbox {
    outline: 2px solid var(--hv-filter-primary);
    outline-offset: 2px;
}

/* Hover state */
.hv-filter-option:not(.is-disabled):hover .hv-filter-option-checkbox {
    border-color: var(--hv-filter-primary);
}

.hv-filter-option-label {
    flex: 1;
    color: var(--hv-filter-text);
}

.hv-filter-option-count {
    font-size: 0.75rem;
    color: var(--hv-filter-text-muted);
    min-width: 1.5rem;
    text-align: right;
}

/* Zero count styling */
.hv-filter-option.is-disabled .hv-filter-option-count {
    color: var(--hv-filter-border);
}

/* ==========================================================================
   Price Range Filter
   ========================================================================== */

.hv-price-range {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.hv-price-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hv-price-input-group {
    display: flex;
    align-items: center;
    flex: 1;
    border: 1px solid var(--hv-filter-border);
    border-radius: var(--hv-filter-radius);
    overflow: hidden;
    transition: border-color var(--hv-filter-transition);
}

.hv-price-input-group:focus-within {
    border-color: var(--hv-filter-primary);
    outline: 2px solid var(--hv-filter-primary);
    outline-offset: -1px;
}

.hv-price-currency {
    padding: 0.5rem;
    background-color: var(--hv-filter-bg-hover);
    color: var(--hv-filter-text-muted);
    font-size: 0.875rem;
}

.hv-price-input {
    width: 100%;
    padding: 0.5rem;
    border: none;
    background: none;
    font-size: 0.875rem;
    color: var(--hv-filter-text);
    outline: none;
    -moz-appearance: textfield;
}

.hv-price-input::-webkit-outer-spin-button,
.hv-price-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.hv-price-separator {
    color: var(--hv-filter-text-muted);
    flex-shrink: 0;
}

/* ==========================================================================
   Price Slider
   ========================================================================== */

.hv-price-slider {
    position: relative;
    height: 1.5rem;
    padding: 0.5rem 0;
}

.hv-price-slider-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background-color: var(--hv-filter-border);
    border-radius: 2px;
    transform: translateY(-50%);
}

.hv-price-slider-range {
    position: absolute;
    top: 0;
    height: 100%;
    background-color: var(--hv-filter-primary);
    border-radius: 2px;
}

.hv-price-slider-thumb {
    position: absolute;
    top: 50%;
    width: 100%;
    height: 4px;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: none;
    transform: translateY(-50%);
}

.hv-price-slider-thumb::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 1rem;
    height: 1rem;
    background-color: var(--hv-filter-bg);
    border: 2px solid var(--hv-filter-primary);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    transition: transform var(--hv-filter-transition), box-shadow var(--hv-filter-transition);
}

.hv-price-slider-thumb::-moz-range-thumb {
    width: 1rem;
    height: 1rem;
    background-color: var(--hv-filter-bg);
    border: 2px solid var(--hv-filter-primary);
    border-radius: 50%;
    cursor: pointer;
    pointer-events: auto;
    transition: transform var(--hv-filter-transition), box-shadow var(--hv-filter-transition);
}

.hv-price-slider-thumb::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(255, 229, 0, 0.2);
}

.hv-price-slider-thumb::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(255, 229, 0, 0.2);
}

.hv-price-slider-thumb:focus::-webkit-slider-thumb {
    outline: 2px solid var(--hv-filter-primary);
    outline-offset: 2px;
}

.hv-price-slider-thumb:focus::-moz-range-thumb {
    outline: 2px solid var(--hv-filter-primary);
    outline-offset: 2px;
}

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

.hv-filter-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: var(--hv-filter-radius);
    z-index: 10;
}

.hv-filter-loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--hv-filter-border);
    border-top-color: var(--hv-filter-primary);
    border-radius: 50%;
    animation: hv-spin 0.8s linear infinite;
}

@keyframes hv-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================================================
   Lazy Loading Counts
   ========================================================================== */

/* Loading state for filter counts (shown while counts are being lazy loaded) */
.hv-filter-count.hv-count-loading {
    position: relative;
    color: transparent !important;
    min-width: 2rem;
}

.hv-filter-count.hv-count-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0.75rem;
    height: 0.75rem;
    margin: -0.375rem 0 0 -0.375rem;
    border: 2px solid var(--hv-filter-border);
    border-top-color: var(--hv-filter-primary);
    border-radius: 50%;
    animation: hv-spin 0.6s linear infinite;
}

/* Subtle pulse animation for count placeholders */
.hv-count-placeholder {
    display: inline-block;
    width: 1.5rem;
    height: 0.75rem;
    background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: hv-skeleton-shimmer 1.2s ease-in-out infinite;
    border-radius: 0.25rem;
    vertical-align: middle;
}

/* ==========================================================================
   Skeleton Loading
   ========================================================================== */

.hv-skeleton-card {
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    border-radius: 0.5rem;
    overflow: hidden;
    gap: 0;
}

.hv-skeleton-image {
    aspect-ratio: 1 / 1;
    background: linear-gradient(90deg, #f5f5f5 25%, #ebebeb 50%, #f5f5f5 75%);
    background-size: 200% 100%;
    animation: hv-skeleton-shimmer 1.5s ease-in-out infinite;
}

.hv-skeleton-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
}

.hv-skeleton-title {
    height: 1rem;
    width: 85%;
    background: linear-gradient(90deg, #f5f5f5 25%, #ebebeb 50%, #f5f5f5 75%);
    background-size: 200% 100%;
    animation: hv-skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 0.25rem;
}

.hv-skeleton-subtitle {
    height: 0.75rem;
    width: 60%;
    background: linear-gradient(90deg, #f5f5f5 25%, #ebebeb 50%, #f5f5f5 75%);
    background-size: 200% 100%;
    animation: hv-skeleton-shimmer 1.5s ease-in-out infinite;
    animation-delay: 0.1s;
    border-radius: 0.25rem;
}

.hv-skeleton-price {
    height: 1.25rem;
    width: 35%;
    margin-top: 0.25rem;
    background: linear-gradient(90deg, #f5f5f5 25%, #ebebeb 50%, #f5f5f5 75%);
    background-size: 200% 100%;
    animation: hv-skeleton-shimmer 1.5s ease-in-out infinite;
    animation-delay: 0.2s;
    border-radius: 0.25rem;
}

@keyframes hv-skeleton-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Fade in animation for products after skeleton */
.products.hv-products-loaded > * {
    animation: hv-fade-in 0.3s ease-out;
}

@keyframes hv-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Product count transition */
.product-count {
    transition: opacity 150ms ease;
}

/* ==========================================================================
   No Products Message
   ========================================================================== */

.hv-no-products {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    background-color: var(--hv-filter-bg-hover);
    border-radius: var(--hv-filter-radius);
}

.hv-no-products p {
    margin: 0 0 1rem;
    color: var(--hv-filter-text-muted);
}

.hv-reset-filters {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--hv-filter-text);
    background-color: var(--hv-filter-primary);
    border: none;
    border-radius: var(--hv-filter-radius);
    cursor: pointer;
    transition: opacity var(--hv-filter-transition);
}

.hv-reset-filters:hover,
.hv-reset-filters:focus {
    opacity: 0.9;
}

.hv-reset-filters:focus {
    outline: 2px solid var(--hv-filter-text);
    outline-offset: 2px;
}

/* ==========================================================================
   Error State
   ========================================================================== */

.hv-filter-error {
    padding: var(--hv-filter-spacing);
    color: #dc2626;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--hv-filter-radius);
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Hidden with x-cloak (Alpine.js) */
[x-cloak] {
    display: none !important;
}

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

@media (max-width: 768px) {
    .hv-filter-sidebar {
        --hv-filter-spacing: 0.75rem;
    }

    .hv-filter-group-content {
        max-height: none;
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .hv-filter-sidebar,
    .hv-filter-sidebar * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
