/**
 * Zehner App — Install-Banner
 *
 * Erscheint unten am Bildschirm (mobile-first), responsive.
 * Bedient Light-/Dark-Theme via prefers-color-scheme.
 */

.zehner-app-banner {
    position: fixed;
    z-index: 999999;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    background: #1a1a1a;
    color: #fff;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    animation: zehner-app-slide-up 0.35s ease-out;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

@media (min-width: 768px) {
    .zehner-app-banner {
        left: auto;
        right: 24px;
        bottom: 24px;
        max-width: 420px;
    }
}

.zehner-app-banner__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.zehner-app-banner__content strong {
    font-weight: 600;
    font-size: 15px;
}

.zehner-app-banner__content span {
    opacity: 0.85;
}

.zehner-app-banner__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.zehner-app-banner__install {
    background: #d63638;        /* Brand-Rot der Buttons */
    color: #fff;
    border: 0;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s;
}

.zehner-app-banner__install:hover {
    background: #b82d2f;
}

.zehner-app-banner__dismiss {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    border: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.zehner-app-banner__dismiss:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

@keyframes zehner-app-slide-up {
    from { transform: translateY(120%); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Standalone-Modus: Banner nicht zeigen, falls App schon installiert */
@media (display-mode: standalone) {
    .zehner-app-banner { display: none !important; }
}

/* ============================================================
 * PUSH-BENACHRICHTIGUNGEN — Bell + Modal + Toast
 * ============================================================ */

.zehner-bell {
    position: fixed;
    z-index: 999998;
    right: 20px;
    bottom: max(20px, env(safe-area-inset-bottom));
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #1a1a1a;
    color: #fff;
    border: 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, background 0.15s;
}

.zehner-bell:hover  { transform: scale(1.05); }
.zehner-bell:active { transform: scale(0.95); }

.zehner-bell--active {
    background: #d63638;
}

.zehner-bell--active::after {
    content: "";
    position: absolute;
    top: 8px;
    right: 8px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #4caf50;
    border: 2px solid #1a1a1a;
}

@media (display-mode: standalone) {
    .zehner-bell { bottom: max(20px, env(safe-area-inset-bottom) + 6px); }
}

/* Wenn der Install-Banner sichtbar ist, Bell höher schieben */
.zehner-app-banner ~ .zehner-bell { bottom: max(90px, env(safe-area-inset-bottom) + 80px); }

/* === MODAL === */
.zehner-push-modal {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: zehner-fade-in 0.2s ease-out;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.zehner-push-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}

.zehner-push-modal__dialog {
    position: relative;
    background: #fff;
    border-radius: 16px;
    padding: 28px 24px 20px;
    max-width: 420px;
    width: calc(100% - 32px);
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: zehner-modal-pop 0.25s ease-out;
}

.zehner-push-modal__close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: 0;
    width: 36px;
    height: 36px;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    border-radius: 8px;
}

.zehner-push-modal__close:hover { background: #f3f3f3; color: #000; }

.zehner-push-modal__dialog h2 {
    margin: 0 0 8px;
    font-size: 20px;
    color: #1a1a1a;
}

.zehner-push-modal__dialog p {
    margin: 0 0 16px;
    color: #555;
    font-size: 14px;
    line-height: 1.5;
}

.zehner-push-modal__topics {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 20px;
    padding: 14px;
    background: #faf7f0;
    border-radius: 10px;
}

.zehner-push-modal__topic {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 4px;
    cursor: pointer;
    font-size: 15px;
    color: #1a1a1a;
}

.zehner-push-modal__topic input { width: 18px; height: 18px; accent-color: #d63638; cursor: pointer; }

.zehner-push-modal__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 8px;
}

.zehner-push-modal__on, .zehner-push-modal__off {
    padding: 10px 18px;
    border-radius: 8px;
    border: 0;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
}
.zehner-push-modal__on  { background: #d63638; color: #fff; }
.zehner-push-modal__off { background: #f3f3f3; color: #666; }
.zehner-push-modal__on:hover  { background: #b82d2f; }
.zehner-push-modal__off:hover { background: #e8e8e8; }

.zehner-push-modal__note {
    margin-top: 12px !important;
    font-size: 12px !important;
    color: #888 !important;
    text-align: center;
}

/* === TOAST === */
.zehner-toast {
    position: fixed;
    z-index: 1000001;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    font-size: 14px;
    animation: zehner-fade-in 0.25s ease-out, zehner-fade-out 0.25s ease-in 2.75s forwards;
}

@keyframes zehner-fade-in   { from { opacity: 0; } to { opacity: 1; } }
@keyframes zehner-fade-out  { to   { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes zehner-modal-pop { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ============================================================
 * ÖFFNUNGSZEITEN-WIDGET — floating bottom-left
 * ============================================================ */
.zehner-oh-widget {
    position: fixed;
    z-index: 999997;
    left: 20px;
    bottom: max(20px, env(safe-area-inset-bottom));
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #1a1a1a;
    color: #fff;
    border: 0;
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    max-width: calc(100vw - 40px - 72px);  /* Platz für Bell rechts lassen */
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.zehner-oh-widget:hover  { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,0.32); }
.zehner-oh-widget:active { transform: translateY(0);    box-shadow: 0 4px 16px rgba(0,0,0,0.25); }
.zehner-oh-widget:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ============================================================
 * ÖFFNUNGSZEITEN-MODAL
 * ============================================================ */
.zehner-oh-modal {
    position: fixed; inset: 0;
    z-index: 999998;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.zehner-oh-modal[hidden] { display: none; }
.zehner-oh-modal__back {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(2px);
    animation: zehner-fade-in 0.18s ease;
}
.zehner-oh-modal__panel {
    position: relative;
    width: 100%; max-width: 380px;
    background: #fff; color: #1a1a1a;
    border-radius: 16px;
    padding: 24px 24px 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    animation: zehner-modal-pop 0.18s ease;
}
.zehner-oh-modal__close {
    position: absolute; top: 8px; right: 12px;
    background: none; border: 0;
    font-size: 28px; line-height: 1; cursor: pointer;
    color: #888; padding: 4px 8px;
}
.zehner-oh-modal__close:hover { color: #1a1a1a; }
.zehner-oh-modal__panel h2 {
    margin: 0 0 16px; font-size: 18px; font-weight: 600;
}
.zehner-oh-modal__table {
    width: 100%; border-collapse: collapse; font-size: 14px;
}
.zehner-oh-modal__table th,
.zehner-oh-modal__table td {
    padding: 8px 4px; text-align: left; border-bottom: 1px solid #eee;
}
.zehner-oh-modal__table th { font-weight: 500; color: #555; width: 40%; }
.zehner-oh-modal__table tr.is-today th,
.zehner-oh-modal__table tr.is-today td { font-weight: 700; color: #1a1a1a; background: #fff8e1; }
.zehner-oh-modal__table .oh-closed { color: #c62828; font-style: italic; }
.zehner-oh-modal__table .oh-note   { display: block; color: #666; font-size: 12px; font-weight: 400; margin-top: 2px; }

body.zehner-oh-modal-open { overflow: hidden; }

.zehner-oh-widget .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #888;
    flex-shrink: 0;
}

.zehner-oh-widget.is-open  .dot { background: #4caf50; box-shadow: 0 0 0 4px rgba(76,175,80,0.25); }
.zehner-oh-widget.is-closed .dot { background: #e57373; }

.zehner-oh-widget.is-open  { background: linear-gradient(135deg, #1a1a1a, #2d2d2d); }
.zehner-oh-widget.is-closed { background: linear-gradient(135deg, #3a1a1a, #1a1a1a); }

.zehner-oh-widget .label  { font-weight: 600; }
.zehner-oh-widget .detail { opacity: 0.75; font-size: 12px; }

/* In Standalone-Mode etwas höher, damit Safe-Area */
@media (display-mode: standalone) {
    .zehner-oh-widget { bottom: max(20px, env(safe-area-inset-bottom) + 6px); }
}

/* Responsive: auf kleinen Screens kompakter */
@media (max-width: 500px) {
    .zehner-oh-widget { font-size: 12px; padding: 8px 12px; }
    .zehner-oh-widget .detail { display: none; }  /* Detail verstecken auf Mobile */
}

/* ============================================================
 * APP-MODE: Bestehendes 'WIR HABEN GEÖFFNET'-Element ausblenden
 * (in der installierten PWA übernimmt mein eigenes Widget unten links die Funktion)
 * ============================================================ */
@media (display-mode: standalone) {
    #open-status-bar { display: none !important; }
}

/* ============================================================
 * APP-MODE: Widget oben mittig (statt unten links)
 * Vermeidet Überlappung mit Theme-Buttons
 * ============================================================ */
@media (display-mode: standalone) {
    /* Altes Element komplett verstecken (override Theme-Inline-Styles) */
    #open-status-bar,
    #open-status-link { display: none !important; }

    /* Widget nach oben Mitte */
    .zehner-oh-widget {
        bottom: auto !important;
        top: calc(8px + env(safe-area-inset-top, 0px)) !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        font-size: 12px !important;
        padding: 6px 14px !important;
        max-width: 80vw !important;
    }
    .zehner-oh-widget .detail { display: inline !important; }
}

/* ============================================================
 * APP BOTTOM-NAVIGATION — nur im Standalone-Mode
 * ============================================================ */
.zehner-nav         { display: none; }
.zehner-more-drawer { display: none; }

@media (display-mode: standalone) {
    /* Body Padding damit Inhalt nicht verdeckt */
    body { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important; }

    /* Existierende Theme-Floating-Buttons unten links ausblenden (Bottom-Nav übernimmt) */
    .open-status-bar-buttons,
    [class*="floating-buttons"],
    .wpcf7-form-control-wrap[class*="cta"] {
        display: none !important;
    }

    .zehner-nav {
        display: flex;
        position: fixed;
        z-index: 999990;
        left: 0;
        right: 0;
        bottom: 0;
        background: #1a1a1a;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -4px 16px rgba(0,0,0,0.25);
        justify-content: space-around;
        align-items: stretch;
    }

    .zehner-nav__item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        padding: 6px 2px;
        color: rgba(255,255,255,0.65);
        text-decoration: none;
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.2px;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
        border-radius: 8px;
        transition: color 0.15s, background 0.15s;
        min-width: 0;
    }

    .zehner-nav__item:hover  { background: rgba(255,255,255,0.06); }
    .zehner-nav__item.is-active {
        color: #fff;
    }
    .zehner-nav__item.is-active .zehner-nav__icon {
        color: #d63638;
    }

    .zehner-nav__icon {
        width: 24px;
        height: 24px;
        color: inherit;
    }
    .zehner-nav__icon svg {
        width: 100%;
        height: 100%;
        display: block;
    }

    .zehner-nav__label {
        font-size: 10px;
        line-height: 1;
        white-space: nowrap;
        overflow: hidden;
        max-width: 100%;
        text-overflow: ellipsis;
    }

    /* Bell + Widget müssen ÜBER der Nav sitzen */
    .zehner-bell {
        bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Widget bleibt oben (siehe vorher) — Bottom-Padding nicht relevant */

    /* === MEHR-DRAWER === */
    .zehner-more-drawer {
        position: fixed;
        inset: 0;
        z-index: 1000001;
        display: flex;
        align-items: flex-end;
        animation: zehner-fade-in 0.2s ease-out;
    }
    .zehner-more-drawer__back {
        position: absolute;
        inset: 0;
        background: rgba(0,0,0,0.5);
    }
    .zehner-more-drawer__panel {
        position: relative;
        background: #fff;
        width: 100%;
        max-width: 480px;
        margin: 0 auto;
        border-radius: 16px 16px 0 0;
        padding: 8px 16px calc(28px + env(safe-area-inset-bottom, 0px));
        animation: zehner-drawer-slide 0.25s ease-out;
    }
    .zehner-more-drawer__handle {
        width: 40px;
        height: 4px;
        background: #ddd;
        border-radius: 2px;
        margin: 6px auto 16px;
    }
    .zehner-more-drawer__list {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    .zehner-more-drawer__list li + li { border-top: 1px solid #f0f0f0; }
    .zehner-more-drawer__list a {
        display: block;
        padding: 16px 12px;
        color: #1a1a1a;
        text-decoration: none;
        font-size: 16px;
        font-weight: 500;
    }
    .zehner-more-drawer__list a:hover { background: #faf7f0; }

    @keyframes zehner-drawer-slide {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
}

/* ============================================================
 * MOBILE-FIX: Bilder in Beiträgen/Speisekarten responsive machen
 * ============================================================ */
@media (max-width: 768px) {
    /* Gutenberg-Bilder (auch is-resized) auf 100% Breite */
    .wp-block-image,
    .wp-block-image figure,
    .wp-block-image.is-resized,
    .wp-block-image.size-full,
    .wp-block-image.size-large {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .wp-block-image img,
    .entry-content img,
    .single-post img,
    .category-speisekarte img,
    .archive img.wp-post-image {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Galerien sauber wrappen */
    .wp-block-gallery,
    .wp-block-columns {
        gap: 8px !important;
    }
    .wp-block-column {
        flex-basis: 100% !important;
        min-width: 0 !important;
    }
}
