/* RAG Bruttozeit-Rechner v1.3 — Frontend */

.ragr {
    --ragr-green: #16a34a;
    --ragr-red: #dc2626;
    --ragr-neutral: #6b7280;
    --ragr-bg: #ffffff;
    --ragr-soft: #f8fafc;
    --ragr-border: #e5e7eb;
    --ragr-text: #1e293b;
    --ragr-muted: #64748b;
    --ragr-accent: #2563eb;
    --ragr-radius: 12px;
    font-family: inherit;
    color: var(--ragr-text);
    line-height: 1.6;
}
.ragr * { box-sizing: border-box; }

/* ═══ Title ═══ */
.ragr__title {
    margin: 0 0 1rem;
    font-size: clamp(18px, 2.5vw, 22px);
}
.ragr__empty {
    background: var(--ragr-soft);
    border: 1px solid var(--ragr-border);
    border-radius: var(--ragr-radius);
    padding: 1.5rem;
    text-align: center;
    color: var(--ragr-muted);
}

/* ═══ Sections (cards) ═══ */
.ragr__section {
    background: var(--ragr-bg);
    border: 1px solid var(--ragr-border);
    border-radius: var(--ragr-radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}
.ragr__section-title {
    margin: 0 0 .35rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ragr-text);
}
.ragr__hint {
    color: var(--ragr-muted);
    font-size: .85rem;
    margin: 0 0 .75rem;
    line-height: 1.5;
}

/* ═══ Badge ═══ */
.ragr__badge {
    display: inline-block;
    background: var(--ragr-accent);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 99px;
    vertical-align: middle;
    margin-left: 6px;
    letter-spacing: .03em;
}

/* ═══ Table (Startversatz) ═══ */
.ragr__table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.ragr__table th,
.ragr__table td {
    padding: .5rem .65rem;
    text-align: left;
    border-bottom: 1px solid var(--ragr-border);
}
.ragr__table th {
    font-size: .75rem;
    font-weight: 700;
    color: var(--ragr-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--ragr-soft);
}
.ragr__row--ref { background: #f0fdf4; }

/* ═══ Color classes ═══ */
.ragr--ahead  { color: var(--ragr-green); font-weight: 700; }
.ragr--behind { color: var(--ragr-red);   font-weight: 700; }
.ragr--neutral { color: var(--ragr-neutral); }

/* ═══ Two-column calculator grid ═══ */
.ragr__calculators {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: stretch;
}
.ragr__calc-col {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
}

/* ═══ Form layout ═══ */
.ragr__form {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    flex: 1;
}
.ragr__field label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    margin-bottom: .3rem;
    color: var(--ragr-text);
}

/* All inputs/selects fill their column */
.ragr__field select,
.ragr__field input[type="number"],
.ragr__field input[type="time"] {
    width: 100%;
    padding: .5rem .65rem;
    border: 1px solid var(--ragr-border);
    border-radius: 8px;
    font-size: .9rem;
    font-family: inherit;
    background: var(--ragr-bg);
    color: var(--ragr-text);
    transition: border-color .15s;
}
.ragr__field select:focus,
.ragr__field input:focus {
    outline: 2px solid var(--ragr-accent);
    outline-offset: -1px;
}

/* ═══ Radio buttons ═══ */
.ragr__radios {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
.ragr__radios label {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    font-weight: 500;
    font-size: .85rem;
    line-height: 1.4;
    cursor: pointer;
}
.ragr__radios input {
    accent-color: var(--ragr-accent);
    margin: 3px 0 0;
    flex-shrink: 0;
}

/* ═══ Fieldsets (TimeStation) ═══ */
.ragr__fieldset {
    border: 1px solid var(--ragr-border);
    border-radius: 8px;
    padding: .65rem .75rem;
    margin: 0;
    background: var(--ragr-soft);
}
.ragr__fieldset legend {
    font-weight: 600;
    font-size: .82rem;
    padding: 0 .4rem;
    color: var(--ragr-text);
}
.ragr__inline {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}
.ragr__inline label {
    font-size: .82rem;
    font-weight: 500;
    color: var(--ragr-muted);
    white-space: nowrap;
}
.ragr__inline select,
.ragr__inline input[type="time"] {
    padding: .4rem .5rem;
    border: 1px solid var(--ragr-border);
    border-radius: 6px;
    font-size: .88rem;
    font-family: inherit;
    background: var(--ragr-bg);
    color: var(--ragr-text);
}
.ragr__inline select:focus,
.ragr__inline input:focus {
    outline: 2px solid var(--ragr-accent);
    outline-offset: -1px;
}

/* ═══ Result box ═══ */
.ragr__result {
    margin-top: .75rem;
    padding: .85rem 1rem;
    border-radius: 8px;
    font-size: .9rem;
    line-height: 1.6;
}
.ragr__result.ragr--ahead {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}
.ragr__result.ragr--behind {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}
.ragr__result.ragr--neutral {
    background: var(--ragr-soft);
    border: 1px solid var(--ragr-border);
    color: var(--ragr-muted);
}
.ragr__detail {
    font-size: .82rem;
    color: var(--ragr-muted);
    margin-bottom: .35rem;
}

/* ═══ Auto-calc hint ═══ */
.ragr__auto-hint {
    font-size: .78rem;
    color: var(--ragr-muted);
    margin-top: auto;
    padding-top: .6rem;
    opacity: .7;
}

/* ═══ Collapsible Startversatz ═══ */
.ragr__collapsible {
    list-style: none;
}
.ragr__collapsible::-webkit-details-marker { display: none; }

.ragr__collapse-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    list-style: none;
    padding: 0;
    margin: 0 0 .5rem;
}
.ragr__collapse-head::-webkit-details-marker { display: none; }
.ragr__collapse-head .ragr__section-title { margin: 0; flex: 1; }

.ragr__chevron {
    font-size: .8rem;
    color: var(--ragr-muted);
    transition: transform .2s;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--ragr-soft);
    flex-shrink: 0;
}
.ragr__collapse-head:hover .ragr__chevron { background: var(--ragr-border); }
.ragr__collapsible[open] > .ragr__collapse-head .ragr__chevron { transform: rotate(180deg); }
.ragr__collapsible:not([open]) > .ragr__collapse-head { margin-bottom: 0; }

.ragr__collapse-body {
    animation: ragr-slide .2s ease;
}
@keyframes ragr-slide {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
    .ragr__calculators { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .ragr__section { padding: 1rem; }
    .ragr__inline { flex-direction: column; align-items: stretch; }
    .ragr__inline select,
    .ragr__inline input[type="time"] { width: 100%; }
}

/* ═══ Dark mode / StrivX dark sections ═══ */
.sx-bg--dark .ragr {
    --ragr-bg: rgba(255,255,255,0.04);
    --ragr-soft: rgba(255,255,255,0.06);
    --ragr-border: rgba(255,255,255,0.1);
    --ragr-text: #f3f4f6;
    --ragr-muted: #9ca3af;
}
.sx-bg--dark .ragr__row--ref { background: rgba(22,163,74,0.1); }
.sx-bg--dark .ragr__field select,
.sx-bg--dark .ragr__field input,
.sx-bg--dark .ragr__inline select,
.sx-bg--dark .ragr__inline input,
.sx-bg--dark .ragr__fieldset {
    background: rgba(255,255,255,0.06);
    color: #f3f4f6;
    border-color: rgba(255,255,255,0.12);
}

/* ═══ TimeStation Supabase elements ═══ */
.ragr__badge--live {
    background: #16a34a;
    animation: ragr-pulse 2s infinite;
}
@keyframes ragr-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}

.ragr__ref-display {
    padding: .5rem .75rem;
    background: var(--ragr-soft);
    border: 1px solid var(--ragr-border);
    border-radius: 8px;
    font-size: .9rem;
    min-height: 38px;
    display: flex;
    align-items: center;
}
.ragr__ref-status { color: var(--ragr-muted); }
.ragr__ref-status--ok { color: var(--ragr-green); font-weight: 600; }
.ragr__ref-status--pending { color: #d97706; }
.ragr__ref-status--warn { color: var(--ragr-red); font-size: .85rem; }

.ragr__ts-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .5rem;
    margin-top: auto;
    padding-top: .6rem;
}
.ragr__ts-updated {
    font-size: .72rem;
    color: var(--ragr-muted);
    opacity: .7;
    white-space: nowrap;
}

.ragr__field-note {
    font-size: .75rem;
    color: var(--ragr-muted);
    margin: .15rem 0 .4rem;
    opacity: .8;
    font-style: italic;
}
