/* ═══════════════════════════════════════════════════════════
   Forms — extracted from TNonline (Login / Settings / FilterBar)
   Field groups, labels, inputs, selects, textareas, icon inputs,
   validation messaging. Teal focus ring throughout.
   ═══════════════════════════════════════════════════════════ */

.tn-form-group {
    margin-bottom: 18px;
}

.tn-form-group:last-of-type {
    margin-bottom: 0;
}

.tn-form-label {
    display: block;
    margin-bottom: 6px;
    font-size: var(--tn-font-size-sm);
    font-weight: 500;
    color: var(--tn-text-secondary);
}

/* Inputs, selects and textareas share one look */
.tn-input,
.tn-select,
.tn-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius);
    font-size: var(--tn-font-size-sm);
    font-family: var(--tn-font-family);
    color: var(--tn-text-primary);
    background: var(--tn-bg-card);
    transition: border-color var(--tn-transition), box-shadow var(--tn-transition);
    outline: none;
}

.tn-input::placeholder,
.tn-textarea::placeholder {
    color: var(--tn-text-muted);
}

.tn-input:focus,
.tn-select:focus,
.tn-textarea:focus {
    border-color: var(--tn-accent);
    box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.1);
}

.tn-input:disabled,
.tn-select:disabled,
.tn-textarea:disabled {
    background-color: var(--tn-bg-page);
    cursor: not-allowed;
    opacity: 0.7;
}

.tn-select {
    cursor: pointer;
    appearance: auto;
}

.tn-textarea {
    min-height: 96px;
    resize: vertical;
    line-height: 1.5;
}

/* ── Input with a leading icon (e.g. login fields) ── */
.tn-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.tn-input-icon {
    position: absolute;
    left: 13px;
    font-size: 0.95rem;
    color: var(--tn-text-muted);
    pointer-events: none;
    z-index: 1;
}

/* Leave room for a leading icon and/or a trailing action, only when present */
.tn-input-wrapper:has(.tn-input-icon) .tn-input {
    padding-left: 40px;
}

.tn-input-wrapper:has(.tn-input-action) .tn-input {
    padding-right: 42px;
}

/* ── Trailing action inside a field (e.g. password show/hide eye) ──
   A real button (clickable, focusable), right-aligned inside the field.
   <div class="tn-input-wrapper">
     <input class="tn-input" type="password">
     <button class="tn-input-action" aria-label="Visa lösenord"><i class="bi bi-eye"></i></button>
   </div>  — swap bi-eye / bi-eye-slash on toggle. */
.tn-input-action {
    position: absolute;
    right: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--tn-radius-sm);
    background: none;
    color: var(--tn-text-muted);
    cursor: pointer;
    transition: color var(--tn-transition), background var(--tn-transition);
}

.tn-input-action:hover {
    color: var(--tn-accent);
    background: var(--tn-bg-hover);
}

.tn-input-action:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px var(--tn-accent);
}

/* ── Password strength meter ──
   Set the level modifier (--weak / --fair / --strong) on .tn-strength from
   your strength calc; fill width + colour and the label tone follow. */
.tn-strength {
    display: flex;
    align-items: center;
    gap: var(--tn-space-sm);
    margin-top: var(--tn-space-xs);
}

.tn-strength-track {
    flex: 1;
    height: 4px;
    border-radius: 999px;
    background: var(--tn-border);
    overflow: hidden;
}

.tn-strength-fill {
    width: 0;
    height: 100%;
    border-radius: 999px;
    transition: width var(--tn-transition), background var(--tn-transition);
}

.tn-strength--weak .tn-strength-fill {
    width: 33%;
    background: var(--tn-danger);
}

.tn-strength--fair .tn-strength-fill {
    width: 66%;
    background: var(--tn-warning);
}

.tn-strength--strong .tn-strength-fill {
    width: 100%;
    background: var(--tn-success);
}

.tn-strength-label {
    font-size: var(--tn-font-size-xs);
    font-weight: 600;
    color: var(--tn-text-secondary);
    white-space: nowrap;
}

.tn-strength--weak .tn-strength-label {
    color: var(--tn-danger-text);
}

.tn-strength--fair .tn-strength-label {
    color: var(--tn-warning-text);
}

.tn-strength--strong .tn-strength-label {
    color: var(--tn-success-text);
}

/* ── Neutral helper text under a field (e.g. "Minst 8 tecken") ── */
.tn-form-hint {
    margin-top: var(--tn-space-xs);
    font-size: var(--tn-font-size-xs);
    color: var(--tn-text-muted);
}

/* ── Validation ── */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid var(--tn-success);
}

.invalid {
    outline: 1px solid var(--tn-danger);
}

.tn-validation-message,
.validation-message {
    color: var(--tn-danger);
    font-size: var(--tn-font-size-xs);
    margin-top: var(--tn-space-xs);
}

/* ── Compact filter inputs (FilterBar) ── */
.tn-filter-field {
    display: flex;
    flex-direction: column;
    gap: var(--tn-space-xs);
}

.tn-filter-label {
    font-size: var(--tn-font-size-xs);
    font-weight: 600;
    color: var(--tn-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tn-filter-input {
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--tn-border);
    border-radius: var(--tn-radius);
    background: var(--tn-bg-card);
    color: var(--tn-text-primary);
    font-size: var(--tn-font-size-sm);
    font-family: inherit;
    transition: border-color var(--tn-transition), box-shadow var(--tn-transition);
    min-width: 150px;
}

.tn-filter-input:focus {
    outline: none;
    border-color: var(--tn-accent);
    box-shadow: 0 0 0 3px rgba(13, 115, 119, 0.1);
}

/* On narrow screens filter fields and inputs span the full width */
@media (max-width: 768px) {
    .tn-filter-field {
        width: 100%;
    }

    .tn-filter-input {
        width: 100%;
        min-width: 0;
    }
}
