/*
 * Formulaires — labels, inputs, selects, textarea, toggle.
 */

/* ============================================================
   Field group (label + input + hint)
   ============================================================ */

.field {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.field__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.field__hint {
    font-size: 12px;
    color: var(--text-faint);
    line-height: 1.4;
}

.field__error {
    font-size: 12px;
    font-weight: 600;
    color: var(--danger);
}

.field--has-error .input,
.field--has-error .textarea,
.field--has-error .select {
    border-color: var(--danger);
}

/* ============================================================
   Inputs
   ============================================================ */

.input,
.textarea,
.select {
    width: 100%;
    padding: 0 14px;
    height: 44px;
    background: var(--surface);
    color: var(--text);
    border: var(--border-width-strong) solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 15px;
    outline: none;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.input::placeholder,
.textarea::placeholder {
    color: var(--text-faint);
}

.input:hover,
.textarea:hover,
.select:hover {
    border-color: var(--border-strong);
}

.input:focus,
.textarea:focus,
.select:focus {
    border-color: var(--accent);
}

.input:disabled,
.textarea:disabled,
.select:disabled {
    background: var(--surface-alt);
    color: var(--text-faint);
    cursor: not-allowed;
}

/* Textarea : hauteur variable */
.textarea {
    min-height: 88px;
    padding: 12px 14px;
    line-height: 1.5;
    resize: vertical;
}

/* Select : flèche custom (cache la flèche système) */
.select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 36px;
    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='%236B5B82' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%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;
    cursor: pointer;
}

[data-theme='dark'] .select {
    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='%23B5A8C9' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

/* ============================================================
   Input avec suffixe (ex: "kg", "kcal", "cm")
   ============================================================ */

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group .input {
    padding-right: 56px;
}

.input-group__suffix {
    position: absolute;
    right: 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-faint);
    pointer-events: none;
}

/* Variante : input grand (chiffre central) */
.input--hero {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-align: center;
    height: 64px;
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   Toggle (switch)
   ============================================================ */

.toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle__track {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.toggle__thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--surface);
    border-radius: 50%;
    transition: transform var(--transition-fast);
    box-shadow: var(--shadow);
}

.toggle input:checked + .toggle__track {
    background: var(--accent);
}

.toggle input:checked + .toggle__track .toggle__thumb {
    transform: translateX(20px);
}

.toggle input:disabled + .toggle__track {
    opacity: 0.5;
    cursor: not-allowed;
}
