/* ========================================
   Global Form Elements Styling
   Consistent dark theme form controls
   ======================================== */

/* ===== Default Checkbox Styling =====
   Apply the styled (dark-theme) checkbox to ALL <input type="checkbox">
   by default. Opt out by adding the .checkbox-native class, or by nesting
   the input inside .toggle-switch / .switch / .setting-toggle (those wrappers
   already hide the input via higher-specificity rules).
*/
input[type="checkbox"]:not(.checkbox-native) {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 22px;
    height: 22px;
    min-width: 22px;
    max-width: 22px;
    aspect-ratio: 1;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    flex-grow: 0;
    margin: 0;
    box-sizing: border-box;
    vertical-align: middle;
}

input[type="checkbox"]:not(.checkbox-native):hover {
    border-color: var(--accent-primary, var(--brand-primary));
    background: rgba(99, 102, 241, 0.1);
}

input[type="checkbox"]:not(.checkbox-native):focus {
    outline: none;
    border-color: var(--accent-primary, var(--brand-primary));
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

input[type="checkbox"]:not(.checkbox-native):checked {
    background: linear-gradient(135deg, var(--accent-primary, var(--brand-primary)) 0%, var(--brand-secondary) 100%);
    border-color: var(--accent-primary, var(--brand-primary));
}

input[type="checkbox"]:not(.checkbox-native):checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 6px;
    height: 11px;
    border: solid white !important;
    border-width: 0 2.5px 2.5px 0 !important;
    transform: rotate(45deg);
}

input[type="checkbox"]:not(.checkbox-native):disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

[data-theme="light"] input[type="checkbox"]:not(.checkbox-native) {
    border-color: #cbd5e1;
    background: #f8fafc;
}

[data-theme="light"] input[type="checkbox"]:not(.checkbox-native):hover {
    border-color: var(--accent-primary, var(--brand-primary));
    background: rgba(99, 102, 241, 0.08);
}

[data-theme="light"] input[type="checkbox"]:not(.checkbox-native):checked {
    background: linear-gradient(135deg, var(--accent-primary, var(--brand-primary)) 0%, var(--brand-secondary) 100%);
    border-color: var(--accent-primary, var(--brand-primary));
}

/* ===== Custom Checkbox (legacy class hooks - now redundant aliases) ===== */
.form-check,
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-check-input,
input[type="checkbox"].custom-checkbox {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 22px;
    height: 22px;
    min-width: 22px;
    max-width: 22px;
    aspect-ratio: 1;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    flex-grow: 0;
    margin: 0;
    box-sizing: border-box;
}

.form-check-input:hover,
input[type="checkbox"].custom-checkbox:hover {
    border-color: var(--accent-primary, var(--brand-primary));
    background: rgba(99, 102, 241, 0.1);
}

.form-check-input:focus,
input[type="checkbox"].custom-checkbox:focus {
    outline: none;
    border-color: var(--accent-primary, var(--brand-primary));
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-check-input:checked,
input[type="checkbox"].custom-checkbox:checked {
    background: linear-gradient(135deg, var(--accent-primary, var(--brand-primary)) 0%, var(--brand-secondary) 100%);
    border-color: var(--accent-primary, var(--brand-primary));
}

.form-check-input:checked::after,
input[type="checkbox"].custom-checkbox:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 6px;
    height: 11px;
    border: solid white !important;
    border-width: 0 2.5px 2.5px 0 !important;
    transform: rotate(45deg);
}

.form-check-label,
.checkbox-label {
    color: var(--text-primary, #ffffff);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Checkbox within label (nested pattern) */
.checkbox-label input[type="checkbox"],
.checkbox-group label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    min-width: 22px;
    max-width: 22px;
    aspect-ratio: 1;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    flex-grow: 0;
    margin: 0;
    box-sizing: border-box;
}

.checkbox-label input[type="checkbox"]:hover,
.checkbox-group label input[type="checkbox"]:hover {
    border-color: var(--accent-primary, var(--brand-primary));
    background: rgba(99, 102, 241, 0.1);
}

.checkbox-label input[type="checkbox"]:checked,
.checkbox-group label input[type="checkbox"]:checked {
    background: linear-gradient(135deg, var(--accent-primary, var(--brand-primary)) 0%, var(--brand-secondary) 100%);
    border-color: var(--accent-primary, var(--brand-primary));
}

.checkbox-label input[type="checkbox"]:checked::after,
.checkbox-group label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 6px;
    height: 11px;
    border: solid white !important;
    border-width: 0 2.5px 2.5px 0 !important;
    transform: rotate(45deg);
}

/* Light mode checkbox styling */
[data-theme="light"] .form-check-input,
[data-theme="light"] input[type="checkbox"].custom-checkbox,
[data-theme="light"] .checkbox-label input[type="checkbox"] {
    border-color: #cbd5e1;
    background: #f8fafc;
}

[data-theme="light"] .form-check-input:hover,
[data-theme="light"] input[type="checkbox"].custom-checkbox:hover,
[data-theme="light"] .checkbox-label input[type="checkbox"]:hover {
    border-color: var(--accent-primary, var(--brand-primary));
    background: rgba(99, 102, 241, 0.08);
}

[data-theme="light"] .form-check-input:checked,
[data-theme="light"] input[type="checkbox"].custom-checkbox:checked,
[data-theme="light"] .checkbox-label input[type="checkbox"]:checked {
    background: linear-gradient(135deg, var(--accent-primary, var(--brand-primary)) 0%, var(--brand-secondary) 100%);
    border-color: var(--accent-primary, var(--brand-primary));
}

[data-theme="light"] .form-check-input:checked::after,
[data-theme="light"] input[type="checkbox"].custom-checkbox:checked::after,
[data-theme="light"] .checkbox-label input[type="checkbox"]:checked::after {
    border-color: white !important;
}

[data-theme="light"] .form-check-label,
[data-theme="light"] .checkbox-label {
    color: #1e293b;
}

/* ===== Checkbox Group ===== */
/* Container for multiple checkboxes in forms */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    margin: 0;
    color: var(--text-primary, #ffffff);
    font-size: 14px;
    font-weight: 500;
}

.checkbox-group label span {
    font-weight: 400;
    text-transform: none;
}

.checkbox-group label small {
    font-weight: 400;
    font-size: 0.85em;
    opacity: 0.7;
}

[data-theme="light"] .checkbox-group label {
    color: #1e293b;
}

/* ===== Toggle Switch ===== */
.toggle-switch,
.switch {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-switch input,
.switch input[type="checkbox"] {
    display: none;
}

.toggle-slider,
.slider {
    width: 48px;
    height: 26px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.toggle-slider::before,
.slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider,
.switch input:checked + .slider {
    background: var(--accent-success, #10b981);
}

.toggle-switch input:checked + .toggle-slider::before,
.switch input:checked + .slider::before {
    transform: translateX(22px);
}

.toggle-label,
.switch-label {
    font-size: 14px;
    color: var(--text-primary, #ffffff);
    font-weight: 500;
}


/* ===== Text Inputs ===== */
/* Unified styling for form-input and form-control - use either class interchangeably */
.form-input,
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border-color, rgba(255, 255, 255, 0.12));
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg, rgba(255, 255, 255, 0.04));
    color: var(--text-primary, #ffffff);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-input:hover,
.form-control:hover,
input:hover:not([type="checkbox"]):not([type="radio"]) {
    border-color: rgba(255, 255, 255, 0.25);
}

.form-input:focus,
.form-control:focus,
input:focus:not([type="checkbox"]):not([type="radio"]),
textarea:focus {
    outline: none;
    border-color: var(--accent-primary, var(--brand-primary));
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-input::placeholder,
.form-control::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--text-muted, rgba(255, 255, 255, 0.4));
}


/* ===== Select Dropdowns ===== */
/* Note: theme.css provides themed select styles with !important - this is fallback */
.form-select,
select:not(.location-select):not(.mobile-location-select) {
    width: 100%;
    padding: 12px 40px 12px 14px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    border-radius: 8px;
    font-size: 14px;
    background-color: var(--input-bg, rgba(255, 255, 255, 0.05));
    color: var(--text-primary, #ffffff);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-select:hover,
select:not(.location-select):not(.mobile-location-select):hover {
    border-color: rgba(255, 255, 255, 0.25);
}

.form-select:focus,
select:not(.location-select):not(.mobile-location-select):focus {
    outline: none;
    border-color: var(--accent-primary, var(--brand-primary));
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-select option,
select:not(.location-select):not(.mobile-location-select) option {
    background: var(--bg-card, #1a1a2e);
    color: var(--text-primary, #ffffff);
    padding: 10px;
}


/* ===== Form Groups ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label:not(.checkbox-label):not(.toggle-switch):not(.switch) {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted, rgba(255, 255, 255, 0.7));
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


/* ===== Radio Buttons ===== */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: var(--text-primary, #ffffff);
    font-size: 14px;
    font-weight: 500;
}

.radio-label input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    min-width: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin: 0;
}

.radio-label input[type="radio"]:hover {
    border-color: var(--accent-primary, var(--brand-primary));
}

.radio-label input[type="radio"]:checked {
    border-color: var(--accent-primary, var(--brand-primary));
    background: var(--accent-primary, var(--brand-primary));
}

.radio-label input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}


/* ===== Small Variants ===== */
.form-input-sm,
.form-control-sm {
    padding: 8px 12px;
    font-size: 13px;
}

.form-select-sm {
    padding: 8px 36px 8px 12px;
    font-size: 13px;
}


/* ===== Disabled States ===== */
.form-input:disabled,
.form-control:disabled,
.form-select:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.02);
}


/* ===== Validation States ===== */
.form-input.is-invalid,
.form-control.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
    border-color: #ef4444;
}

.form-input.is-invalid:focus,
.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.form-input.is-valid,
.form-control.is-valid,
input.is-valid,
select.is-valid,
textarea.is-valid {
    border-color: #10b981;
}

.form-input.is-valid:focus,
.form-control.is-valid:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.invalid-feedback {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #ef4444;
}


/* ===== Input Groups ===== */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-group > input,
.input-group > select {
    flex: 1;
    border-radius: 0;
}

.input-group > *:first-child {
    border-radius: 8px 0 0 8px;
}

.input-group > *:last-child {
    border-radius: 0 8px 8px 0;
}

.input-group-text {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    color: var(--text-muted, rgba(255, 255, 255, 0.6));
    font-size: 14px;
    display: flex;
    align-items: center;
}


/* ===== Number Input Spinners ===== */
input[type="number"] {
    -moz-appearance: textfield;
}

/* Webkit (Chrome, Safari, Edge) spinner buttons */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    width: 28px;
    height: 100%;
    margin: 0;
    margin-right: -14px;
    background: transparent;
    border-left: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    cursor: pointer;
    opacity: 1;
    position: relative;
}

/* Custom number input with visible spinners */
input[type="number"].show-spinners {
    -moz-appearance: auto;
    appearance: auto;
}

/* Style number inputs with custom +/- buttons */
.number-input-wrapper {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    border-radius: 8px;
    background: var(--input-bg, rgba(255, 255, 255, 0.05));
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.number-input-wrapper:hover {
    border-color: rgba(255, 255, 255, 0.25);
}

.number-input-wrapper:focus-within {
    border-color: var(--accent-primary, var(--brand-primary));
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.number-input-wrapper input[type="number"] {
    flex: 1;
    border: none;
    background: transparent;
    text-align: center;
    padding: 10px 8px;
    min-width: 60px;
}

.number-input-wrapper input[type="number"]:focus {
    outline: none;
    box-shadow: none;
}

.number-input-wrapper .spinner-btn {
    width: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary, #ffffff);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    font-size: 18px;
    font-weight: 600;
    border: none;
    padding: 0;
}

.number-input-wrapper .spinner-btn:hover {
    background: var(--accent-primary, var(--brand-primary));
    color: white;
}

.number-input-wrapper .spinner-btn:active {
    background: var(--accent-primary-dark, var(--brand-primary-hover));
    transform: scale(0.95);
}

.number-input-wrapper .spinner-btn.decrement {
    border-right: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}

.number-input-wrapper .spinner-btn.increment {
    border-left: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}

/* Inline number stepper (compact) */
.number-stepper {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    border-radius: 8px;
    overflow: hidden;
    background: var(--input-bg, rgba(255, 255, 255, 0.05));
}

.number-stepper input[type="number"] {
    width: 50px;
    text-align: center;
    border: none;
    background: transparent;
    padding: 8px 4px;
    font-size: 14px;
}

.number-stepper input[type="number"]:focus {
    outline: none;
    box-shadow: none;
}

.number-stepper button {
    width: 32px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary, #ffffff);
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.15s ease;
}

.number-stepper button:hover {
    background: var(--accent-primary, var(--brand-primary));
    color: white;
}

.number-stepper button:active {
    transform: scale(0.9);
}

.number-stepper button:first-child {
    border-right: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}

.number-stepper button:last-child {
    border-left: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
}

