/* components.css — Buttons, Inputs, Modals, generische UI-Komponenten */

/* ─────────────────────────────────────────────────────────────────────── */
/* Buttons                                                                  */
/* ─────────────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: var(--shell-radius);
    border: 1px solid var(--shell-border-strong);
    background: var(--shell-bg-elevated);
    color: var(--shell-fg);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, transform 0.05s;
}

.btn:hover:not(:disabled) {
    background: var(--shell-border);
}

.btn:active:not(:disabled) {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--shell-primary);
    color: var(--shell-primary-fg);
    border-color: var(--shell-primary);
}

.btn-primary:hover:not(:disabled) {
    background: var(--shell-primary-hover);
    border-color: var(--shell-primary-hover);
}

.btn-danger {
    background: var(--shell-danger);
    color: #ffffff;
    border-color: var(--shell-danger);
}

/* Rechte Header-Gruppe: Auth-Badge + Header-Actions, getrennt gruppiert,
 * damit der Badge nicht von clearHeaderActions() weggeraeumt wird.            */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Auth-Probe-Badge — nur auf nicht-prod sichtbar. Drei Zustaende:
 *   .auth-badge-ok       gruen   — gueltiger ALLPLAN-JWT vom Backend bestaetigt
 *   .auth-badge-mock     gelb    — Mock-Token aktiv, kein echter ALLPLAN-Token
 *   .auth-badge-invalid  rot     — Token vorhanden aber abgelehnt
 * Auf Prod ist der Badge versteckt (Element bleibt im DOM via [hidden]).      */
.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.10);
    color: #ffffff;
}
.auth-badge[hidden] { display: none; }
.auth-badge::before {
    content: '';
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: currentColor;
}
.auth-badge-ok      { background: rgba(34, 197, 94, 0.20);  border-color: rgba(34, 197, 94, 0.6); }
.auth-badge-mock    { background: rgba(234, 179, 8, 0.22);  border-color: rgba(234, 179, 8, 0.7); }
.auth-badge-invalid { background: rgba(239, 68, 68, 0.22);  border-color: rgba(239, 68, 68, 0.7); }

/* Header-Buttons: lesbar auf blauem Hintergrund. Secondary = transparenter
 * Outline-Button, Primary = solid weiss mit Primary-Color als Text.            */
.header-actions .btn {
    padding: 0.4rem 0.95rem;
    font-size: 0.875rem;
}
.header-actions .btn:not(.btn-primary) {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.55);
    color: #ffffff;
}
.header-actions .btn:not(.btn-primary):hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.85);
}
.header-actions .btn-primary {
    background: #ffffff;
    color: var(--shell-primary);
    border-color: #ffffff;
}
.header-actions .btn-primary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.88);
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Inputs                                                                   */
/* ─────────────────────────────────────────────────────────────────────── */

.input,
.select {
    padding: 0.5rem 0.75rem;
    border-radius: var(--shell-radius);
    border: 1px solid var(--shell-border-strong);
    background: var(--shell-bg);
    color: var(--shell-fg);
    font-family: inherit;
    font-size: 0.9375rem;
}

.input:focus,
.select:focus {
    outline: 2px solid var(--shell-primary);
    outline-offset: -1px;
    border-color: var(--shell-primary);
}

.input-with-unit {
    display: inline-flex;
    gap: 0.375rem;
    align-items: center;
}

.input-with-unit .input {
    width: 5rem;
}

.input-with-unit .select {
    width: 4rem;
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Modals                                                                   */
/* ─────────────────────────────────────────────────────────────────────── */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: var(--shell-spacing);
}

.modal {
    background: var(--shell-bg);
    color: var(--shell-fg);
    border-radius: var(--shell-radius-lg);
    box-shadow: var(--shell-shadow-modal);
    max-width: 500px;
    width: 100%;
    padding: var(--shell-spacing-lg);
}

.modal-title {
    margin: 0 0 var(--shell-spacing);
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-body {
    margin-bottom: var(--shell-spacing-lg);
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Loading / Spinner                                                        */
/* ─────────────────────────────────────────────────────────────────────── */

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--shell-spacing);
    padding: var(--shell-spacing-lg);
}

.spinner {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 3px solid var(--shell-border);
    border-top-color: var(--shell-primary);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Progress-Overlay (waehrend AI-Upload-Call)                               */
/* ─────────────────────────────────────────────────────────────────────── */

.progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: var(--shell-spacing);
}

.progress-card {
    background: var(--shell-bg);
    color: var(--shell-fg);
    border-radius: var(--shell-radius-lg);
    box-shadow: var(--shell-shadow-modal);
    padding: var(--shell-spacing-lg);
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--shell-spacing);
    text-align: center;
}

.progress-title {
    font-size: 1.0625rem;
    font-weight: 600;
}

.progress-track {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: var(--shell-border);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 5%;
    border-radius: 999px;
    background: var(--shell-primary);
    transition: width 0.3s ease-out;
}

/* Rotierende Pipeline-Stage-Zeile ("Waende werden erkannt…"). min-height
 * verhindert Layout-Springen beim Textwechsel (overtime-Text ist 2-zeilig
 * moeglich). */
.progress-stage {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--shell-fg);
    line-height: 1.4;
    min-height: 1.4em;
}

.progress-hint {
    font-size: 0.875rem;
    color: var(--shell-fg-muted);
    line-height: 1.4;
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Toolbar (top-rechts: Buttons wie "Upload new", "Import this 3D model")  */
/* ─────────────────────────────────────────────────────────────────────── */

.toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-bottom: var(--shell-spacing-lg);
}

/* ─────────────────────────────────────────────────────────────────────── */
/* Toasts — nicht-blockierende Notifications (siehe js/toast.js)             */
/* ─────────────────────────────────────────────────────────────────────── */

.toast-container {
    position: fixed;
    bottom: var(--shell-spacing);
    right: var(--shell-spacing);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: min(420px, calc(100vw - 2 * var(--shell-spacing)));
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.75rem 0.875rem;
    border-radius: var(--shell-radius);
    border-left: 4px solid var(--shell-border-strong);
    background: var(--shell-bg-elevated);
    color: var(--shell-fg);
    box-shadow: var(--shell-shadow-modal);
    font-size: 0.9375rem;
    line-height: 1.4;
    opacity: 0;
    transform: translateX(12px);
    transition: opacity 0.2s, transform 0.2s;
}

.toast-visible {
    opacity: 1;
    transform: translateX(0);
}

.toast-leaving {
    opacity: 0;
    transform: translateX(12px);
}

.toast-error   { border-left-color: var(--shell-danger); }
.toast-success { border-left-color: #2e9e5b; }
.toast-info    { border-left-color: var(--shell-primary); }

.toast-message {
    flex: 1;
    word-break: break-word;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--shell-fg-muted);
    font-size: 1.125rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.125rem;
}

.toast-close:hover {
    color: var(--shell-fg);
}
