/* ============================================================
   RingerDB App-Switcher
   Google-artiges "Waffle"-Menü zum Wechseln zwischen den
   Teilanwendungen (Anträge, Turniere, Ligen, Meldungen,
   Kampfrichter, Verwaltung, Account).

   Alle Klassen sind mit "ringerdb-" praefixiert, damit sie in
   den bestehenden Anwendungen (MudBlazor) nicht kollidieren.
   ============================================================ */

:root {
    --ringerdb-rot: #d7000f;
    --ringerdb-blau: #324681;
    --ringerdb-blau-hell: #0064b4;
    --ringerdb-gelb: #ffce00;

    /* Helles Theme (Default) */
    --ringerdb-bar-fg: #1a1a1a;

    --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: currentColor;
}

/* Dunkles Theme – erzwungen ueber data-ringerdb-theme="dark"
   (an die DarkMode-Einstellung der App gekoppelt). */
[data-ringerdb-theme="dark"] {
    --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;
}

/* ---------------- Brand (Logo + Titel) ---------------- */
.ringerdb-appbar__brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.ringerdb-appbar__logo {
    height: 38px;
    width: auto;
    display: block;
    margin-top: 2px;
}

.ringerdb-appbar__title {
    font-size: 1.15rem;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.05;
}

.ringerdb-appbar__title small {
    display: block;
    font-size: .72rem;
    font-weight: 400;
    color: var(--ringerdb-muted);
    margin-top: -2px;
}

@media only screen and (min-width: 960px) {
    .ringerdb-appbar__logo {
        height: 48px;
        margin-top: 4px;
    }
}

/* ---------------- 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: currentColor;
    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);
    }
}
