/**
 * THC Abbau Rechner – Stylesheet
 *
 * BEM-Namenskonvention: .tar  (Block)
 *                       .tar__element
 *                       .tar__element--modifier
 *
 * Primärfarbe wird per CSS-Variable --tar-primary injiziert.
 */

/* ── Reset & Container ── */
.tar {
    --_primary: var(--tar-primary, #10b981);
    --_primary-hover: color-mix(in srgb, var(--_primary) 85%, #000);
    --_bg: #ffffff;
    --_bg-alt: #f8fafb;
    --_border: #e2e8f0;
    --_text: #1e293b;
    --_text-muted: #64748b;
    --_error: #ef4444;
    --_radius: 8px;
    --_shadow: 0 1px 3px rgba(0, 0, 0, 0.08);

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--_text);
    max-width: 640px;
    margin: 2rem auto;
    padding: 1.5rem;
    background: var(--_bg);
    border: 1px solid var(--_border);
    border-radius: var(--_radius);
    box-shadow: var(--_shadow);
    box-sizing: border-box;
}

.tar *, .tar *::before, .tar *::after {
    box-sizing: border-box;
}

/* ── Felder ── */
.tar__field {
    margin-bottom: 1rem;
}

.tar__field--row {
    display: flex;
    gap: 1rem;
}

.tar__field--half {
    flex: 1;
    min-width: 0;
}

.tar__label {
    display: block;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.35rem;
    color: var(--_text);
}

.tar__required {
    color: var(--_error);
}

.tar__optional {
    font-weight: 400;
    color: var(--_text-muted);
    font-size: 0.8rem;
}

.tar__tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 11px;
    font-weight: 700;
    color: var(--_text-muted);
    border: 1px solid var(--_border);
    border-radius: 50%;
    cursor: help;
    vertical-align: middle;
    margin-left: 4px;
    position: relative;
}

/* ── Inputs ── */
.tar__input {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.9375rem;
    color: var(--_text);
    background: var(--_bg);
    border: 1px solid var(--_border);
    border-radius: var(--_radius);
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

.tar__input:focus {
    border-color: var(--_primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--_primary) 20%, transparent);
}

.tar__input--invalid,
.tar__input:invalid:not(:placeholder-shown) {
    border-color: var(--_error);
}

select.tar__input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.825L0.375 3.2l.85-.85L6 7.125l4.775-4.775.85.85z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

/* ── Radio & Checkbox ── */
.tar__radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-top: 0.25rem;
}

.tar__radio-group--inline {
    margin-bottom: 0.75rem;
}

.tar__radio,
.tar__checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    font-size: 0.9375rem;
    cursor: pointer;
    line-height: 1.4;
}

.tar__radio input,
.tar__checkbox input {
    margin-top: 3px;
    accent-color: var(--_primary);
}

/* ── Fehlermeldungen ── */
.tar__error {
    display: none;
    color: var(--_error);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.tar__error--visible {
    display: block;
}

/* ── Disclaimer-Feld ── */
.tar__field--disclaimer {
    background: var(--_bg-alt);
    border: 1px solid var(--_border);
    border-radius: var(--_radius);
    padding: 0.75rem 1rem;
    margin-top: 1.25rem;
}

/* ── Buttons ── */
.tar__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.7rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--_primary);
    border: none;
    border-radius: var(--_radius);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    margin-top: 0.5rem;
}

.tar__button:hover {
    background: var(--_primary-hover);
}

.tar__button:active {
    transform: scale(0.98);
}

.tar__button--secondary {
    background: transparent;
    color: var(--_primary);
    border: 1px solid var(--_primary);
    margin-top: 1.25rem;
}

.tar__button--secondary:hover {
    background: color-mix(in srgb, var(--_primary) 8%, transparent);
}

/* ── Ergebnisbereich ── */
.tar__result {
    animation: tar-fadein 0.35s ease;
}

@keyframes tar-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tar__result-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 1rem;
    color: var(--_text);
}

/* ── Zusammenfassung ── */
.tar__summary {
    background: var(--_bg-alt);
    border: 1px solid var(--_border);
    border-radius: var(--_radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    line-height: 1.7;
}

.tar__summary-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--_border);
    padding: 0.15rem 0;
}

.tar__summary-row:last-child {
    border-bottom: none;
}

.tar__summary-key {
    font-weight: 600;
    color: var(--_text-muted);
}

/* ── Tabs ── */
.tar__tabs {
    display: flex;
    border-bottom: 2px solid var(--_border);
    margin-bottom: 1rem;
    gap: 0;
}

.tar__tab {
    flex: 1;
    background: none;
    border: none;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--_text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.tar__tab:hover {
    color: var(--_text);
}

.tar__tab--active {
    color: var(--_primary);
    border-bottom-color: var(--_primary);
}

/* ── Tab-Inhalte ── */
.tar__tab-content {
    display: none;
}

.tar__tab-content--active {
    display: block;
    animation: tar-fadein 0.2s ease;
}

/* Zeitraum-Karten */
.tar__range {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.tar__range-card {
    flex: 1;
    text-align: center;
    padding: 0.75rem 0.5rem;
    border: 1px solid var(--_border);
    border-radius: var(--_radius);
    background: var(--_bg-alt);
}

.tar__range-card--typical {
    border-color: var(--_primary);
    background: color-mix(in srgb, var(--_primary) 6%, var(--_bg));
}

.tar__range-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--_text-muted);
    margin-bottom: 0.35rem;
}

.tar__range-card--typical .tar__range-label {
    color: var(--_primary);
}

.tar__range-date {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--_text);
}

.tar__range-time {
    font-size: 0.75rem;
    color: var(--_text-muted);
}

.tar__range-passed {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--_primary);
}

/* ── Einflussfaktoren ── */
.tar__factors {
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    background: var(--_bg-alt);
    border: 1px solid var(--_border);
    border-radius: var(--_radius);
    font-size: 0.85rem;
    line-height: 1.7;
    color: var(--_text-muted);
}

.tar__factors-title {
    font-weight: 700;
    color: var(--_text);
    margin-bottom: 0.35rem;
}

/* ── Haftungsausschluss ── */
.tar__disclaimer {
    margin-top: 1.25rem;
    padding: 0.75rem 1rem;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: var(--_radius);
    font-size: 0.8rem;
    line-height: 1.6;
    color: #92400e;
    font-weight: 500;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .tar {
        padding: 1rem;
        font-size: 14px;
    }
    .tar__field--row {
        flex-direction: column;
        gap: 0;
    }
    .tar__range {
        flex-direction: column;
    }
    .tar__tabs {
        gap: 0;
    }
    .tar__tab {
        font-size: 0.8rem;
        padding: 0.5rem 0.5rem;
    }
}
