/**
 * Visual Swatches Styling
 * 
 * Enhanced visual presentation for color, image, and text swatches
 * with accessibility-compliant focus indicators and responsive design.
 *
 * @package Advanced_Woo_Filters
 * @since   1.1.0
 */

/* ============================================
   BASE SWATCH STYLES
   ============================================ */

.awf-swatch-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.awf-swatch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
}

/* Focus state for accessibility */
.awf-swatch:focus,
.awf-swatch:focus-visible {
    outline: 3px solid #007cba;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.15);
}

/* Hover state */
.awf-swatch:hover {
    border-color: #007cba;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Selected state */
.awf-swatch.awf-selected {
    border-color: #007cba;
    border-width: 3px;
    background: #f0f8ff;
}

.awf-swatch.awf-selected::after {
    content: '\2713'; /* Checkmark */
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: #007cba;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Disabled state */
.awf-swatch.awf-disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.awf-swatch.awf-disabled::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: #ff0000;
    transform: translateY(-50%) rotate(-45deg);
}

/* ============================================
   COLOR SWATCHES
   ============================================ */

.awf-swatch.awf-swatch-color {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    padding: 0;
    overflow: hidden;
}

.awf-swatch-color-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

/* Color swatch with gradient for multi-tone colors */
.awf-swatch-color.awf-multi-tone .awf-swatch-color-inner {
    background: linear-gradient(135deg, var(--color-1) 50%, var(--color-2) 50%);
}

/* Tooltip for color name */
.awf-swatch-color .awf-swatch-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10;
}

.awf-swatch-color:hover .awf-swatch-tooltip,
.awf-swatch-color:focus .awf-swatch-tooltip {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* ============================================
   IMAGE SWATCHES
   ============================================ */

.awf-swatch.awf-swatch-image {
    width: 60px;
    height: 60px;
    padding: 4px;
    border-radius: 8px;
}

.awf-swatch-image-inner {
    width: 100%;
    height: 100%;
    border-radius: 4px;
    overflow: hidden;
}

.awf-swatch-image-inner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Zoom effect on hover */
.awf-swatch-image:hover .awf-swatch-image-inner img {
    transform: scale(1.1);
    transition: transform 0.3s ease;
}

/* ============================================
   TEXT/LABEL SWATCHES
   ============================================ */

.awf-swatch.awf-swatch-text {
    min-width: auto;
    padding: 8px 16px;
    height: auto;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    background: #f5f5f5;
    border: 2px solid #ddd;
}

.awf-swatch-text:hover {
    background: #e8e8e8;
}

.awf-swatch-text.awf-selected {
    background: #007cba;
    color: #fff;
    border-color: #006ba1;
}

/* Size variant for text swatches */
.awf-swatch-text.awf-swatch-small {
    padding: 4px 12px;
    font-size: 12px;
}

.awf-swatch-text.awf-swatch-large {
    padding: 12px 24px;
    font-size: 16px;
}

/* ============================================
   MATRIX VIEW STYLES
   ============================================ */

.awf-matrix-filter {
    margin: 20px 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.awf-matrix-header {
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.awf-matrix-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.awf-matrix-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.awf-matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.awf-matrix-table th,
.awf-matrix-table td {
    padding: 12px;
    text-align: center;
    border: 1px solid #e0e0e0;
}

.awf-matrix-corner {
    background: #f8f9fa;
    font-weight: 600;
    color: #666;
    font-size: 12px;
    text-transform: uppercase;
}

.awf-matrix-header-cell,
.awf-matrix-row-header {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.awf-matrix-cell {
    position: relative;
    padding: 4px;
    background: #fff;
    transition: background-color 0.2s ease;
}

.awf-matrix-cell.awf-available:hover,
.awf-matrix-cell.awf-available:focus {
    background: #f0f8ff;
}

.awf-matrix-cell.awf-unavailable {
    background: #f9f9f9;
}

.awf-matrix-cell-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 60px;
    min-height: 60px;
    padding: 8px;
    border: 2px solid transparent;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
}

.awf-matrix-cell-button:hover,
.awf-matrix-cell-button:focus {
    border-color: #007cba;
    background: #f0f8ff;
    transform: scale(1.05);
}

.awf-matrix-cell-button[aria-pressed="true"] {
    border-color: #007cba;
    background: #007cba;
    color: #fff;
}

.awf-matrix-cell-icon {
    font-size: 20px;
    margin-bottom: 4px;
    opacity: 0.7;
}

.awf-matrix-cell-button[aria-pressed="true"] .awf-matrix-cell-icon {
    opacity: 1;
}

.awf-matrix-cell-count {
    font-size: 12px;
    font-weight: 600;
    color: #666;
}

.awf-matrix-cell-button[aria-pressed="true"] .awf-matrix-cell-count {
    color: #fff;
}

.awf-matrix-cell-empty {
    display: inline-block;
    color: #ccc;
    font-size: 24px;
    font-weight: 300;
}

.awf-matrix-footer {
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    text-align: right;
}

/* ============================================
   RANGE SLIDER STYLES
   ============================================ */

.awf-range-slider-wrapper {
    padding: 20px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin: 20px 0;
}

.awf-range-header {
    margin-bottom: 16px;
}

.awf-range-label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.awf-range-inputs {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.awf-range-input-group {
    flex: 1;
}

.awf-range-input-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #666;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.awf-range-input-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 12px;
    background: #fff;
    transition: border-color 0.2s ease;
}

.awf-range-input-wrapper:focus-within {
    border-color: #007cba;
    box-shadow: 0 0 0 1px #007cba;
}

.awf-range-prefix,
.awf-range-suffix {
    font-size: 14px;
    font-weight: 500;
    color: #666;
}

.awf-range-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    min-width: 0;
    width: 100%;
    -moz-appearance: textfield;
}

.awf-range-input::-webkit-inner-spin-button,
.awf-range-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.awf-range-separator {
    font-size: 18px;
    color: #999;
    font-weight: 300;
}

/* ============================================
   SLIDER CONTAINER & TRACK
   ============================================ */

.awf-range-slider-container {
    position: relative;
    height: 40px;
    margin-bottom: 12px;
}

.awf-range-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    transform: translateY(-50%);
    z-index: 1; /* Below fill and thumbs */
}

.awf-range-track-fill {
    position: absolute;
    height: 100%;
    background: linear-gradient(90deg, #007cba, #0096dc);
    border-radius: 3px;
    transition: all 0.1s ease;
    z-index: 2; /* Above track, below thumbs */
    /* These will be set by JavaScript: */
    left: 0%;
    width: 100%;
}

/* ============================================
   THUMB (INPUT RANGE) BASE STYLES
   ============================================ */

.awf-range-thumb {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 100%;
    height: 20px;
    margin: 0;
    padding: 0;
    background: transparent;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    z-index: 3; /* Above track and fill */
}

/* Higher z-index for max thumb so it's always on top when overlapping */
.awf-range-thumb-max {
    z-index: 4;
}

/* Remove default slider track styling across browsers */
.awf-range-thumb::-webkit-slider-runnable-track {
    background: transparent;
    border: none;
    height: 6px;
}

.awf-range-thumb::-moz-range-track {
    background: transparent;
    border: none;
    height: 6px;
}

.awf-range-thumb::-ms-track {
    background: transparent;
    border: none;
    color: transparent;
    height: 6px;
}

.awf-range-thumb::-ms-fill-lower,
.awf-range-thumb::-ms-fill-upper {
    background: transparent;
}

/* ============================================
   THUMB (HANDLE) STYLES
   ============================================ */

.awf-range-thumb::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007cba;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    cursor: grab;
    pointer-events: all;
    transition: all 0.2s ease;
    position: relative;
    z-index: 10;
}

.awf-range-thumb::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007cba;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    cursor: grab;
    pointer-events: all;
    transition: all 0.2s ease;
    position: relative;
    z-index: 10;
}

.awf-range-thumb::-ms-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007cba;
    border: 3px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    cursor: grab;
    pointer-events: all;
    transition: all 0.2s ease;
}

/* Active (grabbing) state */
.awf-range-thumb:active::-webkit-slider-thumb {
    cursor: grabbing;
}

.awf-range-thumb:active::-moz-range-thumb {
    cursor: grabbing;
}

/* Hover and focus states */
.awf-range-thumb::-webkit-slider-thumb:hover,
.awf-range-thumb::-webkit-slider-thumb:focus {
    background: #006ba1;
    transform: scale(1.2);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.awf-range-thumb::-moz-range-thumb:hover,
.awf-range-thumb::-moz-range-thumb:focus {
    background: #006ba1;
    transform: scale(1.2);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.awf-range-thumb::-ms-thumb:hover,
.awf-range-thumb::-ms-thumb:focus {
    background: #006ba1;
    transform: scale(1.2);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

/* Focus styles for accessibility */
.awf-range-thumb:focus {
    outline: none;
}

.awf-range-thumb:focus-visible::-webkit-slider-thumb {
    outline: 3px solid #007cba;
    outline-offset: 2px;
}

.awf-range-thumb:focus-visible::-moz-range-thumb {
    outline: 3px solid #007cba;
    outline-offset: 2px;
}

/* ============================================
   RANGE LABELS
   ============================================ */

.awf-range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .awf-swatch-container {
        gap: 6px;
    }
    
    .awf-swatch {
        min-width: 36px;
        min-height: 36px;
    }
    
    .awf-swatch.awf-swatch-color {
        width: 36px;
        height: 36px;
    }
    
    .awf-swatch.awf-swatch-image {
        width: 50px;
        height: 50px;
    }
    
    .awf-matrix-table th,
    .awf-matrix-table td {
        padding: 8px;
        font-size: 12px;
    }
    
    .awf-matrix-cell-button {
        min-width: 50px;
        min-height: 50px;
    }
    
    .awf-range-inputs {
        flex-direction: column;
        gap: 8px;
    }
    
    .awf-range-separator {
        display: none;
    }
}

@media (max-width: 480px) {
    .awf-swatch.awf-swatch-text {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .awf-matrix-table {
        font-size: 11px;
    }
    
    .awf-matrix-cell-button {
        min-width: 40px;
        min-height: 40px;
        padding: 4px;
    }
    
    .awf-matrix-cell-icon {
        font-size: 16px;
    }
    
    .awf-matrix-cell-count {
        font-size: 10px;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .awf-swatch-container,
    .awf-matrix-filter,
    .awf-range-slider-wrapper {
        break-inside: avoid;
    }
    
    .awf-swatch:hover,
    .awf-matrix-cell-button:hover,
    .awf-range-thumb:hover {
        transform: none;
        box-shadow: none;
    }
}