/* ========================================
   Global Form Elements Styling
   Consistent dark theme form controls
   ======================================== */

/* ===== Custom Checkbox ===== */
.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;
    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;
    margin: 0;
}

.form-check-input:hover,
input[type="checkbox"].custom-checkbox:hover {
    border-color: var(--accent-primary, #6366f1);
    background: rgba(99, 102, 241, 0.1);
}

.form-check-input:focus,
input[type="checkbox"].custom-checkbox:focus {
    outline: none;
    border-color: var(--accent-primary, #6366f1);
    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, #6366f1) 0%, #8b5cf6 100%);
    border-color: var(--accent-primary, #6366f1);
}

.form-check-input:checked::after,
input[type="checkbox"].custom-checkbox:checked::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 7px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    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"] {
    appearance: none;
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    min-width: 22px;
    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;
    margin: 0;
}

.checkbox-label input[type="checkbox"]:hover {
    border-color: var(--accent-primary, #6366f1);
    background: rgba(99, 102, 241, 0.1);
}

.checkbox-label input[type="checkbox"]:checked {
    background: linear-gradient(135deg, var(--accent-primary, #6366f1) 0%, #8b5cf6 100%);
    border-color: var(--accent-primary, #6366f1);
}

.checkbox-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 7px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}


/* ===== 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 ===== */
.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: 1px solid var(--border-color, rgba(255, 255, 255, 0.15));
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg, rgba(255, 255, 255, 0.05));
    color: var(--text-primary, #ffffff);
    transition: border-color 0.2s ease, box-shadow 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, #6366f1);
    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 ===== */
.form-select,
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;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-select:hover,
select:hover {
    border-color: rgba(255, 255, 255, 0.25);
}

.form-select:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.form-select option,
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, #6366f1);
}

.radio-label input[type="radio"]:checked {
    border-color: var(--accent-primary, #6366f1);
    background: var(--accent-primary, #6366f1);
}

.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, #6366f1);
    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, #6366f1);
    color: white;
}

.number-input-wrapper .spinner-btn:active {
    background: var(--accent-primary-dark, #4f46e5);
    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, #6366f1);
    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));
}
