/* ============================================================
   RingerDB App-Switcher – Prototyp
   Google-artiges "Waffle"-Menü zum Wechseln zwischen den
   Teilanwendungen (Anträge, Turniere, Ligen, Kampfrichter,
   Account, Wiegeliste, Verwaltung).

   Alle Klassen sind mit "ringerdb-" praefixiert, damit sie in den
   bestehenden Anwendungen (MudBlazor / ASP) nicht kollidieren.
   ============================================================ */

:root {
    --ringerdb-rot: #d7000f;
    --ringerdb-blau: #324681;
    --ringerdb-blau-hell: #0064b4;
    --ringerdb-gelb: #ffce00;

    /* Helles Theme (Default) */
    --ringerdb-bar-bg: #ffffff;
    --ringerdb-bar-fg: #1a1a1a;
    --ringerdb-bar-border: rgba(0, 0, 0, .08);
    --ringerdb-bar-shadow: 0 2px 6px rgba(0, 0, 0, .12);

    --ringerdb-panel-bg: #ffffff;
    --ringerdb-panel-fg: #1a1a1a;
    --ringerdb-panel-shadow: 0 8px 28px rgba(0, 0, 0, .22);
    --ringerdb-panel-border: rgba(0, 0, 0, .08);

    --ringerdb-tile-hover: rgba(0, 0, 0, .06);
    --ringerdb-tile-active-bg: rgba(215, 0, 15, .10);
    --ringerdb-tile-active-ring: var(--ringerdb-rot);
    --ringerdb-muted: #667085;
    --ringerdb-dot: #5f6368;
}

/* Dunkles Theme – automatisch nach Systemeinstellung ... */
@media (prefers-color-scheme: dark) {
    :root:not([data-ringerdb-theme="light"]) {
        --ringerdb-bar-bg: #1e1e24;
        --ringerdb-bar-fg: #f2f2f5;
        --ringerdb-bar-border: rgba(255, 255, 255, .10);
        --ringerdb-bar-shadow: 0 2px 8px rgba(0, 0, 0, .5);

        --ringerdb-panel-bg: #26262e;
        --ringerdb-panel-fg: #f2f2f5;
        --ringerdb-panel-shadow: 0 8px 30px rgba(0, 0, 0, .6);
        --ringerdb-panel-border: rgba(255, 255, 255, .08);

        --ringerdb-tile-hover: rgba(255, 255, 255, .08);
        --ringerdb-tile-active-bg: rgba(215, 0, 15, .22);
        --ringerdb-muted: #a2a2ad;
        --ringerdb-dot: #c7c7cf;
    }
}

/* ... oder erzwungen ueber data-ringerdb-theme="dark" (an die
   DarkMode-Einstellung der App koppeln). */
[data-ringerdb-theme="dark"] {
    --ringerdb-bar-bg: #1e1e24;
    --ringerdb-bar-fg: #f2f2f5;
    --ringerdb-bar-border: rgba(255, 255, 255, .10);
    --ringerdb-bar-shadow: 0 2px 8px rgba(0, 0, 0, .5);

    --ringerdb-panel-bg: #26262e;
    --ringerdb-panel-fg: #f2f2f5;
    --ringerdb-panel-shadow: 0 8px 30px rgba(0, 0, 0, .6);
    --ringerdb-panel-border: rgba(255, 255, 255, .08);

    --ringerdb-tile-hover: rgba(255, 255, 255, .08);
    --ringerdb-tile-active-bg: rgba(215, 0, 15, .22);
    --ringerdb-muted: #a2a2ad;
    --ringerdb-dot: #c7c7cf;
}

/* ---------------- AppBar (nur fuer die Demo) ---------------- */
.ringerdb-appbar {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 60px;
    padding: 0 12px 0 16px;
    background: var(--ringerdb-bar-bg);
    color: var(--ringerdb-bar-fg);
    border-bottom: 1px solid var(--ringerdb-bar-border);
    box-shadow: var(--ringerdb-bar-shadow);
    font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
}

.ringerdb-appbar__logo {
    height: 38px;
    width: auto;
    display: block;
}

.ringerdb-appbar__title {
    font-size: 1.15rem;
    font-weight: 600;
    white-space: nowrap;
}

.ringerdb-appbar__title small {
    display: block;
    font-size: .72rem;
    font-weight: 400;
    color: var(--ringerdb-muted);
    margin-top: -2px;
}

.ringerdb-appbar__spacer {
    flex: 1 1 auto;
}

/* ---------------- Waffle-Button ---------------- */
.ringerdb-switcher {
    position: relative;
    font-family: "Segoe UI", Roboto, system-ui, -apple-system, sans-serif;
}

.ringerdb-waffle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--ringerdb-dot);
    cursor: pointer;
    transition: background-color .15s ease;
    -webkit-tap-highlight-color: transparent;
}

.ringerdb-waffle:hover,
.ringerdb-waffle:focus-visible {
    background: var(--ringerdb-tile-hover);
    outline: none;
}

.ringerdb-waffle svg {
    width: 22px;
    height: 22px;
    display: block;
}

/* ---------------- Popup-Panel ---------------- */
.ringerdb-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    max-width: calc(100vw - 24px);
    background: var(--ringerdb-panel-bg);
    color: var(--ringerdb-panel-fg);
    border: 1px solid var(--ringerdb-panel-border);
    border-radius: 16px;
    box-shadow: var(--ringerdb-panel-shadow);
    padding: 10px;
    z-index: 1300;

    /* Ein-/Ausblenden */
    opacity: 0;
    transform: translateY(-6px) scale(.98);
    transform-origin: top right;
    pointer-events: none;
    transition: opacity .14s ease, transform .14s ease;
}

.ringerdb-switcher.is-open .ringerdb-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ringerdb-panel__header {
    font-size: .72rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ringerdb-muted);
    padding: 6px 8px 10px;
}

/* ---------------- Kachel-Raster ---------------- */
.ringerdb-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
}

.ringerdb-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 6px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    text-align: center;
    position: relative;
    transition: background-color .12s ease;
    -webkit-tap-highlight-color: transparent;
}

.ringerdb-tile:hover,
.ringerdb-tile:focus-visible {
    background: var(--ringerdb-tile-hover);
    outline: none;
}

.ringerdb-tile__icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ringerdb-tile__icon svg {
    width: 40px;
    height: 40px;
    display: block;
}

.ringerdb-tile__label {
    font-size: .8rem;
    line-height: 1.15;
    font-weight: 500;
}

/* Aktuelle Anwendung hervorgehoben */
.ringerdb-tile.is-current {
    background: var(--ringerdb-tile-active-bg);
}

.ringerdb-tile.is-current .ringerdb-tile__label {
    color: var(--ringerdb-rot);
    font-weight: 700;
}

.ringerdb-tile.is-current::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 12px;
    border: 2px solid var(--ringerdb-tile-active-ring);
    pointer-events: none;
}

/* kleiner "Sie sind hier"-Punkt an der aktuellen Kachel */
.ringerdb-tile.is-current .ringerdb-tile__icon::after {
    content: "";
    position: absolute;
    top: 10px;
    right: 22px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ringerdb-rot);
    box-shadow: 0 0 0 2px var(--ringerdb-panel-bg);
}

/* ---------------- Backdrop (mobil) ---------------- */
.ringerdb-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: none;
}

.ringerdb-switcher.is-open .ringerdb-backdrop {
    display: block;
}

@media (max-width: 480px) {
    .ringerdb-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 18px 18px 0 0;
        transform-origin: bottom center;
        transform: translateY(12px);
    }

    .ringerdb-switcher.is-open .ringerdb-panel {
        transform: translateY(0);
    }
}

/* ============================================================
   Integration in die MudBlazor-AppBar (wiederverwendbar).
   Der App-Switcher wird direkt in die <MudAppBar> eingebettet.
   Damit er in allen Anwendungen identisch aussieht, bleiben die
   ringerdb-*-Klassen unveraendert; hier nur die noetige Einbettung.
   ============================================================ */

/* Logo + Titel links in der AppBar */
.ringerdb-appbar__brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

/* Waffle uebernimmt die Vordergrundfarbe der AppBar (Kontrast) */
.mud-appbar .ringerdb-waffle {
    color: inherit;
}

.mud-appbar .ringerdb-waffle:hover,
.mud-appbar .ringerdb-waffle:focus-visible {
    background: rgba(255, 255, 255, .15);
}

/* Titel im farbigen MudAppBar-Kontext lesbar halten */
.mud-appbar .ringerdb-appbar__title {
    color: inherit;
}

.mud-appbar .ringerdb-appbar__title small {
    color: inherit;
    opacity: .72;
}
