/**
 * Modern ON/OFF Toggle Switch Styles
 * Replaces checkboxes with beautiful toggle switches
 * iOS and cross-browser compatible
 */

/* Toggle Switch Container - applied to parent .checkbox div */
.toggle-switch-wrapper {
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    gap: 10px;
}

/* Hide the original checkbox */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 70px;
    height: 34px;
    flex-shrink: 0;
    -webkit-flex-shrink: 0;
    /* iOS touch optimization */
    -webkit-tap-highlight-color: transparent;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
    /* iOS: Ensure checkbox is still accessible */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* The switch track/slider background */
.toggle-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #3a3a3a;
    -webkit-transition: 0.3s;
    transition: 0.3s;
    border-radius: 34px;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
    -webkit-justify-content: flex-start;
    justify-content: flex-start;
    padding: 0 8px;
    /* iOS: Prevent text selection on tap */
    -webkit-user-select: none;
    user-select: none;
}

/* OFF text */
.toggle-switch .slider::before {
    content: 'OFF';
    position: absolute;
    right: 10px;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    -webkit-transition: 0.3s;
    transition: 0.3s;
}

/* The circular knob */
.toggle-switch .slider::after {
    content: '';
    position: absolute;
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: #f87171;
    -webkit-transition: 0.3s;
    transition: 0.3s;
    border-radius: 50%;
    -webkit-box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border: 2px solid #fff;
}

/* Checked state - move knob to right */
.toggle-switch input:checked + .slider::after {
    -webkit-transform: translateX(36px);
    transform: translateX(36px);
    background-color: #5bd06c;
}

/* Checked state - change text to ON */
.toggle-switch input:checked + .slider::before {
    content: 'ON';
    left: 12px;
    right: auto;
}

/* Focus state for accessibility */
.toggle-switch input:focus + .slider {
    box-shadow: 0 0 0 2px rgba(91, 208, 108, 0.3);
}

/* Disabled state */
.toggle-switch input:disabled + .slider {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Label styling when toggle is part of a form group */
.toggle-switch-label {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin-bottom: 0;
}

.toggle-switch-label .label-text {
    font-weight: normal;
    color: #333;
}

/* Override iCheck styling for toggle switches */
.checkbox.use-toggle-switch > label,
.form-group .use-toggle-switch > label {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding-left: 0 !important;
}

/* Hide iCheck elements when using toggle switch */
.use-toggle-switch .icheckbox_square-blue,
.use-toggle-switch .iradio_square-blue,
.use-toggle-switch div[class^="icheckbox"],
.use-toggle-switch div[class^="iradio"] {
    display: none !important;
}

/* Dark theme support */
[data-theme="dark"] .toggle-switch .slider {
    background-color: #4a4a4a;
}

[data-theme="dark"] .toggle-switch-label .label-text {
    color: #e0e0e0;
}

/* Compact version for tight spaces */
.toggle-switch.toggle-sm {
    width: 56px;
    height: 28px;
}

.toggle-switch.toggle-sm .slider::after {
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
}

.toggle-switch.toggle-sm input:checked + .slider::after {
    -webkit-transform: translateX(28px);
    transform: translateX(28px);
}

.toggle-switch.toggle-sm .slider::before {
    font-size: 9px;
    right: 7px;
}

.toggle-switch.toggle-sm input:checked + .slider::before {
    left: 8px;
}

/* Large version */
.toggle-switch.toggle-lg {
    width: 84px;
    height: 40px;
}

.toggle-switch.toggle-lg .slider::after {
    height: 32px;
    width: 32px;
    left: 4px;
    bottom: 4px;
}

.toggle-switch.toggle-lg input:checked + .slider::after {
    -webkit-transform: translateX(44px);
    transform: translateX(44px);
}

.toggle-switch.toggle-lg .slider::before {
    font-size: 13px;
    right: 12px;
}

.toggle-switch.toggle-lg input:checked + .slider::before {
    left: 14px;
}

/* Business Settings specific styling */
.pos-tab-content .toggle-switch-wrapper,
.business-settings .toggle-switch-wrapper {
    margin: 8px 0;
}

/* Ensure proper vertical alignment in form groups */
.form-group .toggle-switch-wrapper {
    min-height: 34px;
    display: -webkit-flex;
    display: flex;
    -webkit-align-items: center;
    align-items: center;
}

/* iOS specific: Ensure touch targets are large enough (44px minimum) */
@supports (-webkit-touch-callout: none) {
    .toggle-switch {
        min-height: 44px;
        padding: 5px 0;
    }
}

/* Animation for the knob */
@-webkit-keyframes togglePulse {
    0%, 100% { -webkit-transform: scale(1); transform: scale(1); }
    50% { -webkit-transform: scale(1.05); transform: scale(1.05); }
}
@keyframes togglePulse {
    0%, 100% { -webkit-transform: scale(1); transform: scale(1); }
    50% { -webkit-transform: scale(1.05); transform: scale(1.05); }
}

.toggle-switch input:checked + .slider::after {
    -webkit-animation: togglePulse 0.3s ease-out;
    animation: togglePulse 0.3s ease-out;
}
