/**
 * Styles de formulaires - Style Bootstrap moderne
 */

/* Groupes de formulaire */
.form-group {
    margin-bottom: 1rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

/* Labels */
.form-label {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.form-label.required::after,
.form-label:has(+ input[required])::after,
.form-label:has(+ select[required])::after,
.form-label:has(+ textarea[required])::after {
    content: '*';
    color: #dc2626;
    margin-left: 4px;
}

/* Inputs, Select, Textarea */
.form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    background-clip: padding-box;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    font-family: inherit;
}

.form-control:focus {
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border-color: #7c3aed;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.form-control::placeholder {
    color: #9ca3af;
    opacity: 1;
}

.form-control:disabled,
.form-control[readonly] {
    background-color: #f3f4f6;
    opacity: 1;
    cursor: not-allowed;
}

/* Select spécifique */
select.form-control {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding-right: 2.5rem;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Textarea */
textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* Petits inputs */
.form-control-sm {
    padding: 0.375rem 0.5rem;
    font-size: 13px;
    border-radius: 4px;
}

/* Grands inputs */
.form-control-lg {
    padding: 0.625rem 1rem;
    font-size: 16px;
    border-radius: 8px;
}

/* Texte d'aide */
.form-help,
.form-text {
    display: block;
    margin-top: 0.375rem;
    font-size: 12px;
    color: var(--text-secondary);
}

/* États de validation */
.form-control.is-invalid {
    border-color: #dc2626;
}

.form-control.is-invalid:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-control.is-valid {
    border-color: #10b981;
}

.form-control.is-valid:focus {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.invalid-feedback {
    display: none;
    margin-top: 0.375rem;
    font-size: 12px;
    color: #dc2626;
}

.form-control.is-invalid ~ .invalid-feedback {
    display: block;
}

.valid-feedback {
    display: none;
    margin-top: 0.375rem;
    font-size: 12px;
    color: #10b981;
}

.form-control.is-valid ~ .valid-feedback {
    display: block;
}

/* Disposition en ligne */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.form-row-3 {
    grid-template-columns: repeat(3, 1fr);
}

.form-row-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Checkbox et Radio */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 1.5rem;
    margin-bottom: 0.5rem;
}

.form-check-input {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background-color: var(--bg-primary);
    transition: all 0.15s ease-in-out;
}

.form-check-input[type="checkbox"] {
    border-radius: 4px;
}

.form-check-input[type="radio"] {
    border-radius: 50%;
}

.form-check-input:checked {
    background-color: #7c3aed;
    border-color: #7c3aed;
}

.form-check-input:focus {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.form-check-label {
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    user-select: none;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #7c3aed;
}

/* Input groups */
.input-group {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.input-group .form-control {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    background-color: #f3f4f6;
    border: 1px solid #d1d5db;
}

.input-group > :not(:first-child):not(.dropdown-menu) {
    margin-left: -1px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.input-group > :not(:last-child):not(.dropdown-menu) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

/* Actions du formulaire */
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.form-actions-right {
    justify-content: flex-end;
}

.form-actions-between {
    justify-content: space-between;
}

/* Responsive */
@media (max-width: 768px) {
    .form-row,
    .form-row-3,
    .form-row-4 {
        grid-template-columns: 1fr;
    }
}

/* Dark theme */
body.dark-theme .form-control {
    border-color: #4b5563;
    background-color: var(--bg-primary);
}

body.dark-theme .form-control:focus {
    border-color: #7c3aed;
}

body.dark-theme .form-control:disabled,
body.dark-theme .form-control[readonly] {
    background-color: rgba(75, 85, 99, 0.3);
}

body.dark-theme select.form-control {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23cbd5e1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

body.dark-theme .input-group-text {
    background-color: rgba(75, 85, 99, 0.3);
    border-color: #4b5563;
}

body.dark-theme .form-check-input {
    border-color: #4b5563;
}
