/**
 * Barn2 iOS Switch Styles
 * Complete iOS-style switch for Ready/On Demand filtering
 * YOUR EXISTING CSS CODE
 */

/* Main container */
.ios-switch-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: Plus Jakarta Sans, sans-serif;
    position: relative;
    z-index: 0;
    background: #f5f5f5;
    border-radius: 3px;
    height: 32px;
    margin: 0;
    margin-right: 10px;
    padding: 0 10px;
}

/* Main label */
.ios-switch-label {
    font-size: 14px;
    color: #6B7280 !important;
    font-weight: 600;
    position: absolute;
    top: -25px;
    left: 0;
    white-space: nowrap;
}

/* Info icon */
.ios-switch-info-icon {
    cursor: pointer;
    color: #6B7280;
    font-size: 14px;
    margin-left: 4px;
    display: inline-block;
    position: absolute;
    top: -25px;
    left: 90px;
    z-index: 1001;
}

.ios-switch-info-icon:hover {
    color: #555;
}

/* Tooltip container */
.ios-switch-tooltip-container {
    position: absolute;
    top: 5px;
    left: 0;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
    width: 240px;
    z-index: 1000;
    display: none;
}

/* Triangle pointer */
.ios-switch-tooltip-container:before {
    content: '';
    position: absolute;
    top: -6px;
    left: 15px;
    width: 10px;
    height: 10px;
    background-color: #f5f5f5;
    border-left: 1px solid #ddd;
    border-top: 1px solid #ddd;
    transform: rotate(45deg);
}

/* Tooltip content */
.ios-switch-tooltip-content {
    font-size: 11px;
    line-height: 1.3;
    color: #555;
}

.tooltip-ready strong {
    color: #34c759;
}

.tooltip-on-demand strong {
    color: #ff9500;
}

/* Wrapper for switch and side labels */
.ios-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Side labels (On Demand / Ready) */
.ios-switch-side-label {
    font-size: 14px;
    color: #666;
    transition: color 0.3s ease;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    padding: 2px 4px;
    border-radius: 3px;
    position: relative;
}

.ready:after {
    margin-bottom: 2px;
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #00FF9D;
    border-radius: 50%;
    margin-left: 8px;
    vertical-align: middle;
    animation: pulse-dot 1s infinite;
}

@keyframes pulse-dot {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(0, 255, 157, 0.4);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(0, 255, 157, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(0, 255, 157, 0);
    }
}

.ios-switch-side-label:hover {
    color: #0056b3;
    background-color: rgba(0, 123, 255, 0.1);
}

.ios-switch-side-label.active {
    color: #007AFF;
}

.ios-switch-side-label.active:hover {
    color: #0056b3;
}

/* The main iOS switch */
.ios-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background-color: #34c759; /* Green for "Ready" */
    border-radius: 20px;
    transition: background-color 0.3s ease;
    cursor: pointer;
    display: inline-block;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.ios-switch:hover {
    opacity: 0.9;
    transform: scale(1.02);
    transition: all 0.2s ease;
}

.ios-switch:active {
    transform: scale(0.98);
}

.ios-switch.on-demand {
    background-color: #ff9500; /* Orange for "On Demand" */
}

/* The sliding circle inside the switch */
.ios-switch-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transform: translateX(16px); /* Start on the right for "Ready" */
}

.ios-switch.on-demand .ios-switch-slider {
    transform: translateX(0); /* Move to left for "On Demand" */
}

/* Hide converted Select2 containers and original selects */
.select2-container.ios-converted,
.barn2-filter.ios-converted {
    display: none !important;
}

select.ios-converted {
    display: none !important;
}

/* Integration with Barn2 Product Tables */
.wcpt-wrapper .ios-switch-container,
.barn2-product-table .ios-switch-container {
    margin: 10px 5px;
}

.wcpt-filters .ios-switch-container {
    display: inline-flex;
    margin-right: 20px;
    vertical-align: middle;
}

.wcpt-search-form .ios-switch-container {
    margin: 8px 0;
}

@media (max-width: 1024px) {
    .ios-switch-container {
        margin-bottom: 25px !important;
    }
}

/* Responsive design for mobile */
@media (max-width: 768px) {
    .ios-switch-container {
        flex-direction: row;
        align-items: center;
        gap: 6px;
    }
    
    .ios-switch-wrapper {
        gap: 4px;
        align-self: stretch;
        justify-content: center;
    }
    
    .ios-switch-side-label {
        font-size: 14px;
        padding: 2px 3px;
    }
    
    .ios-switch {
        width: 32px;
        height: 18px;
    }
    
    .ios-switch-slider {
        width: 14px;
        height: 14px;
        transform: translateX(14px);
    }
    
    .ios-switch.on-demand .ios-switch-slider {
        transform: translateX(0);
    }
}

/* Very small screens (phones) */
@media (max-width: 480px) {
    .ios-switch-container {
        gap: 4px;
    }
    
    .ios-switch-wrapper {
        gap: 3px;
    }
    
    .ios-switch-label {
        font-size: 14px;
    }
    
    .ios-switch-side-label {
        font-size: 14px;
        padding: 1px 2px;
    }
    
    .ios-switch {
        width: 28px;
        height: 16px;
    }
    
    .ios-switch-slider {
        width: 12px;
        height: 12px;
        transform: translateX(12px);
    }
    
    .ios-switch.on-demand .ios-switch-slider {
        transform: translateX(0);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .ios-switch-label {
        color: #fff;
    }
    
    .ios-switch-side-label {
        color: #ccc;
    }
    
    .ios-switch-side-label.active {
        color: #007AFF;
    }
    
    .ios-switch-side-label:hover {
        color: #4A9EFF;
        background-color: rgba(74, 158, 255, 0.1);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ios-switch {
        border: 2px solid #000;
    }
    
    .ios-switch-slider {
        border: 1px solid #000;
    }
    
    .ios-switch-side-label {
        border: 1px solid transparent;
    }
    
    .ios-switch-side-label.active {
        border-color: #007AFF;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ios-switch,
    .ios-switch-slider,
    .ios-switch-side-label {
        transition: none;
    }
    
    .ios-switch:hover {
        transform: none;
    }
}

/* Loading state */
.ios-switch-container.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Print styles */
@media print {
    .ios-switch-container {
        display: none;
    }
}