/* komponenten/Layoutverwaltung/assets/css/knoepfe.css */

/* ==========================================================================
   1. STANDARD KNÖPFE (Inline Buttons)
   ========================================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 0.375rem;
    font-weight: 500;
    line-height: 1.25;
    transition: all 0.2s ease-in-out;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none !important;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid #4f46e5;
    outline-offset: 2px;
}

.btn svg {
    width: 1rem;
    height: 1rem;
}

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn-md { padding: 0.5rem 1rem; font-size: 0.875rem; }

.btn-primary { background-color: #4f46e5; color: #ffffff; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.btn-primary:hover { background-color: #4338ca; }

.btn-secondary { background-color: #ffffff; border-color: #d1d5db; color: #374151; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.btn-secondary:hover { background-color: #f9fafb; color: #4f46e5; border-color: #c7d2fe; }

.btn-danger { background-color: #fee2e2; color: #991b1b; border-color: #fecaca; }
.btn-danger:hover { background-color: #fca5a5; color: #7f1d1d; }


/* ==========================================================================
   2. FLOATING ACTIONS (Sticky Buttons) – Desktop-Verhalten unverändert
   ========================================================================== */

.floating-container {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: calc(100% - 2rem);
    display: flex;
    flex-direction: row-reverse;
    flex-wrap: wrap-reverse;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    z-index: 999;
    pointer-events: none;
}

.floating-item {
    pointer-events: auto;
    flex-shrink: 0;
}

.floating-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: 9999px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    cursor: pointer;
    text-decoration: none !important;
    white-space: nowrap;
    line-height: 1.25;
    min-width: 140px;
}

.floating-btn svg {
    width: 1.25rem;
    height: 1.25rem;
}

.floating-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.floating-btn:active { transform: translateY(0) scale(0.98); }

@media (min-width: 1600px) {
    .floating-container {
        left: 50%;
        transform: translateX(624px);
        width: auto;
        max-width: none;
        padding-right: 0;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: flex-start;
        justify-content: flex-end;
    }
    .floating-btn {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        min-width: 160px;
    }
}

.floating-btn-primary { background-color: #4f46e5; color: #ffffff; border: 1px solid transparent; }
.floating-btn-primary:hover { background-color: #4338ca; }

.floating-btn-danger { background-color: #dc2626; color: #ffffff; border: 1px solid transparent; }
.floating-btn-danger:hover { background-color: #b91c1c; }

.floating-btn-secondary { background-color: #ffffff; border: 1px solid #d1d5db; color: #374151; }
.floating-btn-secondary:hover { background-color: #f9fafb; color: #111827; border-color: #9ca3af; }


/* ==========================================================================
   3. MOBILE: EINZIEHBARE SCHWEBEKNÖPFE (Slide-out Rail)
   --------------------------------------------------------------------------
   Aktiviert per schwebeknoepfe.js. Wichtig in dieser Version:
   Der GRIFF ist ein EIGENSTÄNDIGES Element am rechten Rand (Kind der Rail,
   NICHT des Knopf-Stapels). Dadurch kann er nie mit dem Stapel abgeschnitten
   werden und ist IMMER sichtbar/antippbar. Der Stapel gleitet dahinter hervor.
   Bewusst ohne verschachtelte @media und ohne min()/clamp() (Minifier-sicher).
   ========================================================================== */

@media (max-width: 767px) {

    .fab-rail {
        position: fixed;
        top: 0;
        right: 0;
        height: 100%;
        width: 92vw;
        max-width: 340px;
        overflow: hidden;         /* fängt den ausgeschobenen Stapel ab */
        pointer-events: none;     /* Seiteninhalt bleibt bedienbar */
        z-index: 999;
    }

    /* GRIFF – fest bei 25% vom unteren Seitenrand (75% von oben), immer sichtbar */
    .fab-handle {
        position: absolute;
        right: 0;
        top: 75%;
        transform: translateY(-50%);
        width: 30px;
        height: 54px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #6366f1;
        color: #ffffff;
        border: none;
        border-radius: 11px 0 0 11px;
        box-shadow: -3px 0 9px -3px rgba(0, 0, 0, 0.22);
        cursor: pointer;
        pointer-events: auto;
        z-index: 3;
        opacity: 0.55;
        touch-action: none;
        -webkit-tap-highlight-color: transparent;
        transition: opacity 0.25s ease, background 0.2s ease;
    }
    .fab-handle:hover,
    .fab-handle:active,
    .fab-rail.is-open .fab-handle { opacity: 1; }
    .fab-handle:active { background: #4f46e5; }
    .fab-handle:focus-visible { outline: 2px solid #a5b4fc; outline-offset: 2px; opacity: 1; }
    .fab-handle svg { width: 18px; height: 18px; transition: transform 0.3s ease; }
    .fab-rail.is-open .fab-handle svg { transform: rotate(180deg); }

    .fab-rail.hint .fab-handle { animation: fabHandleHint 1.5s ease-in-out 2; }
    @keyframes fabHandleHint {
        0%, 100% { transform: translateY(-50%) translateX(0); }
        50%      { transform: translateY(-50%) translateX(-7px); }
    }

    /* Dauerhaftes Blinken des Griffs, solange Anmerkungen vorliegen und die
       Leiste eingeklappt ist. Wird per .has-notes gesetzt; im offenen Zustand
       (is-open) unterdrückt, weil der Knopf selbst dann sichtbar blinkt. */
    .fab-rail.has-notes:not(.is-open) .fab-handle {
        animation: fabHandleNote 1.1s ease-in-out infinite;
        opacity: 1;
    }
    @keyframes fabHandleNote {
        0%, 100% { background: #6366f1; box-shadow: -3px 0 9px -3px rgba(0, 0, 0, 0.22); }
        50%      { background: #dc2626; box-shadow: -3px 0 14px -1px rgba(220, 38, 38, 0.7); }
    }

    /* KNOPF-STAPEL – gleitet hinter dem Griff hervor, rechtsbündig, untereinander.
       Jeder Knopf ist nur so breit wie sein Inhalt (kein stretch), und der
       gesamte Stapel wird am rechten Rand ausgerichtet (align-items: flex-end). */
    .fab-rail .floating-container {
        position: absolute;
        right: 40px;              /* Platz für den Griff */
        top: 82%;
        left: auto;
        bottom: auto;
        margin: 0;
        padding: 0;
        width: auto;              /* Breite ergibt sich aus dem breitesten Knopf */
        max-width: 82vw;          /* Sicherheitsgrenze für sehr lange Beschriftungen */
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: flex-end;    /* rechtsbündig */
        justify-content: center;
        gap: 0.6rem;
        pointer-events: auto;
        touch-action: pan-y;
        z-index: 2;
        transform: translate(var(--fab-x, 120%), -50%);   /* Start: eingeklappt */
        transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    }
    .fab-rail.is-open .floating-container       { --fab-x: 0px; }
    .fab-rail:not(.is-open) .floating-container { --fab-x: 120%; }
    .fab-rail.is-dragging .floating-container   { transition: none; }

    .fab-rail .floating-item {
        max-width: 100%;          /* an den Stapel gebunden, aber nicht gestreckt */
    }

    .fab-rail .floating-btn {
        min-width: 0;
        width: auto;              /* auf den Inhalt abgestimmte Länge */
        max-width: 100%;
        justify-content: flex-start;
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
        border-radius: 9999px;
    }
    .fab-rail .floating-btn svg { width: 1.25rem; height: 1.25rem; flex: 0 0 auto; }
    .fab-rail .floating-btn > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .fab-rail .floating-btn:hover { transform: none; }

    /* Eingeklappt aus Tab-/Screenreader-Fluss nehmen (Griff bleibt erreichbar) */
    .fab-rail:not(.is-open) .floating-container .floating-item {
        visibility: hidden;
        transition: visibility 0s linear 0.32s;
    }
    .fab-rail.is-open .floating-container .floating-item,
    .fab-rail.is-dragging .floating-container .floating-item {
        visibility: visible;
        transition: visibility 0s linear 0s;
    }
}

@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
    .fab-rail .floating-container { transition: none; }
    .fab-rail.hint .fab-handle { animation: none; }
    .fab-rail.has-notes:not(.is-open) .fab-handle { animation: none; opacity: 1; }
    .fab-handle svg { transition: none; }
}
