/* =====================================================
   CLAUX - FORMS
   ===================================================== */

.form-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: block;
}

.form-control,
.form-select {
    border: 1px solid var(--border-light) !important;
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 0.875rem;
    color: var(--text-primary) !important;
    background: var(--bg-tertiary) !important;
    transition: var(--transition);
    width: 100%;
    font-family: inherit;
    font-weight: 400;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 2px var(--accent-dim);
    outline: none;
}

/* Dark theme input enforcement */
input,
select,
textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="search"],
input[type="tel"],
input[type="url"] {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-light) !important;
    color-scheme: dark;
}

input:focus,
select:focus,
textarea:focus {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

select option {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

/* Firefox dropdown fix */
@-moz-document url-prefix() {
    select {
        background-color: var(--bg-tertiary) !important;
        color: var(--text-primary) !important;
    }

    select option {
        background-color: var(--bg-secondary) !important;
        color: var(--text-primary) !important;
    }
}

/* Autofill override */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bg-tertiary) inset !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    caret-color: var(--text-primary);
    border: 1px solid var(--border-light) !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Disabled state */
input:disabled,
select:disabled,
textarea:disabled,
button:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-secondary) !important;
    color: var(--text-muted) !important;
}

/* Placeholder */
input::placeholder,
textarea::placeholder,
.form-control::placeholder {
    color: var(--text-muted) !important;
    opacity: 1;
}

input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
    color: var(--text-muted) !important;
    opacity: 1;
}

input::-moz-placeholder,
textarea::-moz-placeholder {
    color: var(--text-muted) !important;
    opacity: 1;
}

/* Date picker icon */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.6;
    cursor: pointer;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Textarea */
textarea {
    min-height: 100px;
    resize: vertical;
}

/* Modal input overrides */
.modal input,
.modal select,
.modal textarea {
    background: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-light) !important;
}

.modal input:focus,
.modal select:focus,
.modal textarea:focus {
    background: var(--bg-tertiary) !important;
}

/* ── CHECKBOXES ───────────────────────────────────── */
.form-check {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    margin-bottom: 0;
}

.form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    cursor: pointer;
    border: 2px solid var(--border-light);
    background-color: var(--bg-tertiary);
    transition: var(--transition);
    flex-shrink: 0;
}

.form-check-input:hover {
    border-color: var(--success);
}

.form-check-input:focus {
    border-color: var(--success);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
    outline: none;
}

.form-check-input:checked {
    background-color: var(--success);
    border-color: var(--success);
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}

.form-check-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    margin: 0;
    transition: var(--transition);
}

.form-check-input:checked+.form-check-label {
    color: var(--text-primary);
    font-weight: 600;
}


/* ── SWITCHES ─────────────────────────────────────── */
.form-switch {
    padding: 0 !important;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0;
    min-height: 40px;
    /* Match form-control height */
}

.form-switch .form-check-input {
    width: 56px;
    height: 28px;
    border-radius: 6px;
    margin: 0 !important;
    padding: 0;
    flex-shrink: 0;
    background-color: var(--danger);
    background-image: none;
    border: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    position: relative;
    transition: background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* OFF label */
.form-switch .form-check-input::after {
    content: 'OFF';
    position: absolute;
    left: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.9);
    opacity: 1;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

/* Toggle knob */
.form-switch .form-check-input::before {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: linear-gradient(180deg, #ffffff 0%, #f0f0f0 100%);
    top: 2px;
    right: 2px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3),
        0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Hover state - unchecked (RED) */
.form-switch .form-check-input:hover:not(:checked) {
    background-color: #e53935;
    box-shadow: 0 0 8px rgba(244, 67, 54, 0.4),
        inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.form-switch .form-check-input:hover:not(:checked)::before {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4),
        0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Focus state */
.form-switch .form-check-input:focus {
    border: none;
    outline: none;
}

.form-switch .form-check-input:focus:not(:checked) {
    box-shadow: 0 0 0 4px rgba(244, 67, 54, 0.15),
        inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.form-switch .form-check-input:focus:checked {
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.15),
        inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Checked state (GREEN) */
.form-switch .form-check-input:checked {
    background-color: var(--success);
    background-image: none;
    border: none;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.form-switch .form-check-input:checked::before {
    transform: translateX(-28px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25),
        0 1px 3px rgba(0, 0, 0, 0.15);
}

/* ON label */
.form-switch .form-check-input:checked::after {
    content: 'ON';
    left: auto;
    right: 7px;
    opacity: 1;
}

/* Hover state - checked (GREEN) */
.form-switch .form-check-input:checked:hover {
    background-color: #43a047;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.4),
        inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.form-switch .form-check-input:checked:hover::before {
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3),
        0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Active/pressed state */
.form-switch .form-check-input:active::before {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* Disabled state */
.form-switch .form-check-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.form-switch .form-check-input:disabled+.form-check-label {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Label */
.form-switch .form-check-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    margin: 0;
    padding: 0;
    line-height: 1.5;
    display: inline-block;
    transition: color 0.2s ease;
}

.form-switch .form-check-input:checked+.form-check-label {
    color: var(--text-primary);
}

/* Spacing adjustments for different contexts */
.card-body .form-switch {
    margin-bottom: 16px;
    min-height: 28px;
}

.card-body .form-switch:first-child {
    margin-top: 0;
}

.card-body .form-switch:last-child {
    margin-bottom: 0;
}

/* Modal/form grid alignment */
.modal .form-switch,
.row .form-switch {
    margin-bottom: 0;
    margin-top: 2px;
}
