/**
 * WooCommerce Grid iOS Switch Styles
 */

/* Filter wrapper - positions above grid */
.ios-switch-filter-wrapper {
    margin-bottom: 20px;
    padding: 15px 0;
}

/* Main container */
.ios-switch-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
    position: relative;
    background: #f5f5f5;
    border-radius: 8px;
    padding: 10px 15px;
}

/* Label */
.ios-switch-label {
    font-size: 14px;
    color: #6B7280;
    font-weight: 600;
    white-space: nowrap;
}

/* Info icon */
.ios-switch-info-icon {
    cursor: pointer;
    color: #6B7280;
    font-size: 14px;
    margin-left: 2px;
    transition: color 0.2s ease;
}

.ios-switch-info-icon:hover {
    color: #374151;
}

/* Tooltip */
.ios-switch-tooltip-container {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 280px;
    z-index: 1000;
    display: none;
}

.ios-switch-tooltip-container::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    width: 10px;
    height: 10px;
    background-color: #fff;
    border-left: 1px solid #e5e7eb;
    border-top: 1px solid #e5e7eb;
    transform: rotate(45deg);
}

.ios-switch-tooltip-content {
    font-size: 12px;
    line-height: 1.5;
    color: #4b5563;
}

.ios-switch-tooltip-content strong {
    color: #111827;
}

.tooltip-ready strong {
    color: #059669;
}

.tooltip-on-demand strong {
    color: #d97706;
}

/* Switch wrapper */
.ios-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

/* Side labels */
.ios-switch-side-label {
    font-size: 14px;
    color: #9ca3af;
    transition: color 0.3s ease;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    border-radius: 4px;
}

.ios-switch-side-label:hover {
    color: #6b7280;
    background-color: rgba(0, 0, 0, 0.04);
}

.ios-switch-side-label.active {
    color: #111827;
    font-weight: 600;
}

/* Ready indicator dot */
.ios-switch-side-label.ready.active::after {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #00FF9D;
    border-radius: 50%;
    margin-left: 6px;
    vertical-align: middle;
    animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(0, 255, 157, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 8px rgba(0, 255, 157, 0);
    }
}

/* The switch itself */
.ios-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #10b981;
    border-radius: 24px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    flex-shrink: 0;
}

.ios-switch:hover {
    opacity: 0.9;
}

.ios-switch:active {
    transform: scale(0.98);
}

.ios-switch.on-demand {
    background-color: #f59e0b;
}

/* The slider knob */
.ios-switch-slider {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.ios-switch.on-demand .ios-switch-slider {
    transform: translateX(-20px);
}

/* Responsive */
@media (max-width: 768px) {
    .ios-switch-filter-wrapper {
        padding: 10px 0;
    }
    
    .ios-switch-container {
        flex-wrap: wrap;
        padding: 8px 12px;
    }
    
    .ios-switch-label {
        font-size: 13px;
    }
    
    .ios-switch-side-label {
        font-size: 13px;
        padding: 2px 4px;
    }
    
    .ios-switch {
        width: 40px;
        height: 22px;
    }
    
    .ios-switch-slider {
        width: 18px;
        height: 18px;
    }
    
    .ios-switch.on-demand .ios-switch-slider {
        transform: translateX(-18px);
    }
}

@media (max-width: 480px) {
    .ios-switch-container {
        width: 100%;
        justify-content: center;
    }
    
    .ios-switch-wrapper {
        margin-left: 0;
        margin-top: 8px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ios-switch,
    .ios-switch-slider,
    .ios-switch-side-label,
    ul.products li.product {
        transition: none !important;
    }
    
    .ios-switch-side-label.ready.active::after {
        animation: none;
    }
}

/* Loading state */
.ios-switch-container.loading {
    opacity: 0.7;
    pointer-events: none;
}

.ios-switch-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 10px;
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Print - hide filter */
@media print {
    .ios-switch-filter-wrapper {
        display: none;
    }
}
