import QtQuick
import QtQuick.Controls

Switch {
    id: control

    Accessible.role: Accessible.CheckBox
    Accessible.name: control.text + (control.checked ? " on" : " off")
    activeFocusOnTab: true

    indicator: Rectangle {
        implicitWidth: 44
        implicitHeight: 24
        x: control.leftPadding
        y: parent.height / 2 - height / 2
        radius: 12
        color: control.checked ? SettingsStyle.accent : "#2d2d3d"
        border.color: control.checked ? SettingsStyle.accent : SettingsStyle.borderSubtle
        border.width: control.activeFocus ? SettingsStyle.focusRingWidth : 1

        Behavior on color { ColorAnimation { duration: 200 } }
        Behavior on border.color { ColorAnimation { duration: 200 } }

        Rectangle {
            x: control.checked ? parent.width - width - 3 : 3
            y: 3
            width: 18
            height: 18
            radius: 9
            color: "white"

            Behavior on x {
                NumberAnimation { duration: 200; easing.type: Easing.InOutQuad }
            }

            // I/O pip marks for non-color state indication
            Text {
                anchors.centerIn: parent
                text: control.checked ? "I" : "O"
                font.pixelSize: 9
                font.bold: true
                color: control.checked ? SettingsStyle.accent : "#666666"
            }
        }
    }

    contentItem: Text {
        text: control.text
        font: control.font
        opacity: enabled ? 1.0 : 0.3
        color: "white"
        verticalAlignment: Text.AlignVCenter
        leftPadding: control.indicator.width + control.spacing
    }
}
