/* ============================================================
 * Becker Reisen – Mobile Framework
 * Eingeführt in v6.8.0.
 *
 * Schlankes Opt-in-Utility-System für Mobile-UX-Muster.
 * Naming: .br-m-* (Mobile-Utility), .br-toast (global).
 *
 * Verwendung:
 *   - Utilities pro Seite ergänzen wo nötig
 *   - Global eingebunden via AssetsHelper::loadMobileFramework()
 *
 * Variablen kommen aus beckerreisen.css (:root):
 *   --br-primary, --br-warm-bg, --br-surface, --br-border, etc.
 * ============================================================ */

/* ── iOS-Autozoom-Fix für Inputs ─────────────────────────────
 * iOS zoomt rein, sobald Input-font-size < 16px. Global setzen.
 * ============================================================ */
@media (max-width: 767px) {
    .br-m-form input[type="text"],
    .br-m-form input[type="email"],
    .br-m-form input[type="tel"],
    .br-m-form input[type="number"],
    .br-m-form input[type="password"],
    .br-m-form input[type="search"],
    .br-m-form input[type="url"],
    .br-m-form input[type="date"],
    .br-m-form select,
    .br-m-form textarea {
        font-size: 16px !important;
        min-height: 44px;
    }
    .br-m-form textarea {
        min-height: 88px;
    }
}

/* ── Touch-Target ──────────────────────────────────────────── */
@media (hover: none) and (pointer: coarse) {
    .br-m-touch-target {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* ── Safe-Area-Utilities ───────────────────────────────────── */
.br-m-safe-top    { padding-top:    env(safe-area-inset-top, 0); }
.br-m-safe-bottom { padding-bottom: env(safe-area-inset-bottom, 0); }
.br-m-safe-left   { padding-left:   env(safe-area-inset-left, 0); }
.br-m-safe-right  { padding-right:  env(safe-area-inset-right, 0); }
.br-m-safe-sides  {
    padding-left:  env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

/* ── Visibility ────────────────────────────────────────────── */
.br-m-only-mobile  { display: none; }
.br-m-hide-mobile  { display: revert; }
@media (max-width: 767px) {
    .br-m-only-mobile { display: revert; }
    .br-m-hide-mobile { display: none !important; }
}
.br-m-only-desktop { display: revert; }
.br-m-hide-desktop { display: revert; }
@media (max-width: 767px) {
    .br-m-only-desktop { display: none !important; }
}
@media (min-width: 768px) {
    .br-m-hide-desktop { display: none !important; }
}

/* ============================================================
 * TOAST — Inline-Feedback statt nativem alert()
 * ============================================================ */
.br-toast-host {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10010;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
    width: calc(100% - 2rem);
    max-width: 420px;
    padding-top: env(safe-area-inset-top, 0);
}
.br-toast {
    pointer-events: auto;
    background: var(--br-text, #1f1a14);
    color: #fff;
    padding: .75rem 2.5rem .75rem 1rem;
    border-radius: var(--br-radius, 10px);
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
    font-size: .95rem;
    line-height: 1.35;
    position: relative;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .18s ease, transform .18s ease;
    word-break: break-word;
}
.br-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}
.br-toast--info    { background: var(--br-primary, #773E18); }
.br-toast--success { background: var(--br-green, #2e6b3e); }
.br-toast--warn    { background: var(--br-amber, #92580a); }
.br-toast--error   { background: var(--br-red,   #9b1c1c); }
.br-toast__close {
    position: absolute;
    top: .35rem;
    right: .5rem;
    background: none;
    border: none;
    color: rgba(255,255,255,.85);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: .25rem .4rem;
    min-width: 32px;
    min-height: 32px;
}
.br-toast__close:hover { color: #fff; }
.br-toast__title {
    display: block;
    font-weight: 700;
    margin-bottom: .15rem;
}
.br-toast__action {
    display: inline-block;
    margin-top: .4rem;
    color: #fff;
    text-decoration: underline;
    font-weight: 600;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
}

/* ============================================================
 * BOTTOM-SHEET
 * ============================================================ */
.br-m-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 10000;
    opacity: 0;
    transition: opacity .2s ease;
    pointer-events: none;
}
.br-m-sheet-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}
.br-m-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--br-warm-bg, #FAF8EC);
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
    box-shadow: 0 -8px 32px rgba(0,0,0,.18);
    z-index: 10001;
    transform: translateY(100%);
    transition: transform .25s cubic-bezier(.2,.7,.2,1);
    padding: .75rem 0 0 0;
    max-height: 85vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.br-m-sheet.is-open {
    transform: translateY(0);
}
.br-m-sheet::before {
    content: '';
    display: block;
    width: 40px;
    height: 4px;
    margin: 0 auto .75rem;
    background: var(--br-border, #d4cfc5);
    border-radius: 2px;
}
.br-m-sheet-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--br-text, #1f1a14);
    padding: .25rem 1.25rem 1rem;
    text-align: center;
}
.br-m-sheet-option {
    display: flex;
    align-items: center;
    gap: .9rem;
    padding: .9rem 1.25rem;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 1rem;
    color: var(--br-text, #1f1a14);
    cursor: pointer;
    border-top: 1px solid var(--br-border-soft, #e8e4da);
    min-height: 56px;
}
.br-m-sheet-option:hover,
.br-m-sheet-option:active {
    background: var(--br-surface, #E6E4D9);
}
.br-m-sheet-option-icon {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--br-primary, #773E18);
}
.br-m-sheet-option-icon svg { width: 24px; height: 24px; }
.br-m-sheet-option-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.br-m-sheet-option-label { font-weight: 600; }
.br-m-sheet-option-hint  {
    font-size: .82rem;
    color: var(--br-text-soft, #7a6a56);
    margin-top: .15rem;
}
.br-m-sheet-option--danger { color: var(--br-red, #9b1c1c); }
.br-m-sheet-option--danger .br-m-sheet-option-icon { color: var(--br-red, #9b1c1c); }
.br-m-sheet-option--checked {
    background: var(--br-primary-light, #f2e9e2);
}
.br-m-sheet-option--checked .br-m-sheet-option-label {
    color: var(--br-primary, #773E18);
}
.br-m-sheet-cancel {
    display: block;
    width: calc(100% - 2.5rem);
    margin: 1rem 1.25rem;
    padding: .85rem 1rem;
    background: var(--br-surface, #E6E4D9);
    border: none;
    border-radius: var(--br-radius, 10px);
    font-size: 1rem;
    font-weight: 600;
    color: var(--br-text, #1f1a14);
    cursor: pointer;
    min-height: 48px;
}

/* ============================================================
 * DRAWER (Off-Canvas)
 * ============================================================ */
.br-m-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 10000;
    opacity: 0;
    transition: opacity .2s ease;
    pointer-events: none;
}
.br-m-drawer-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}
.br-m-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    width: min(85vw, 360px);
    background: var(--br-warm-bg, #FAF8EC);
    z-index: 10001;
    transition: transform .25s cubic-bezier(.2,.7,.2,1);
    overflow-y: auto;
    padding: env(safe-area-inset-top, 0) 0 env(safe-area-inset-bottom, 0);
    box-shadow: 0 4px 24px rgba(0,0,0,.18);
}
.br-m-drawer--left  { left:  0; transform: translateX(-100%); }
.br-m-drawer--right { right: 0; transform: translateX(100%); }
.br-m-drawer.is-open { transform: translateX(0); }
.br-m-drawer-close {
    position: absolute;
    top: .5rem;
    right: .5rem;
    background: none;
    border: none;
    color: var(--br-text-soft, #7a6a56);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    min-width: 44px;
    min-height: 44px;
}

/* ============================================================
 * STICKY ACTION BAR (untere persistente Aktionsleiste)
 * Nur sichtbar ≤767px.
 * ============================================================ */
.br-m-sticky-bar {
    display: none;
}
@media (max-width: 767px) {
    .br-m-sticky-bar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        gap: .5rem;
        padding: .65rem .75rem;
        padding-bottom: calc(.65rem + env(safe-area-inset-bottom, 0));
        background: rgba(255,255,255,.96);
        backdrop-filter: blur(8px);
        border-top: 1px solid var(--br-border, #d4cfc5);
        box-shadow: 0 -2px 12px rgba(0,0,0,.06);
        z-index: 100;
    }
    /* Wenn Sticky-Bar präsent: Bottom-Padding für Body, damit nichts überdeckt wird */
    body.br-has-sticky-bar {
        padding-bottom: 80px !important;
    }
}
.br-m-sticky-bar-btn {
    flex: 1 1 0;
    min-height: 48px;
    padding: .75rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--br-radius, 10px);
    border: none;
    cursor: pointer;
    background: var(--br-primary, #773E18);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    text-decoration: none;
    line-height: 1.2;
}
.br-m-sticky-bar-btn:hover,
.br-m-sticky-bar-btn:focus {
    background: var(--br-primary-dark, #5c2e10);
    color: #fff;
    text-decoration: none;
}
.br-m-sticky-bar-btn--secondary {
    background: var(--br-surface, #E6E4D9);
    color: var(--br-text, #1f1a14);
}
.br-m-sticky-bar-btn--secondary:hover,
.br-m-sticky-bar-btn--secondary:focus {
    background: var(--br-border, #d4cfc5);
    color: var(--br-text, #1f1a14);
}
.br-m-sticky-bar-btn:disabled {
    opacity: .55;
    cursor: wait;
}

/* ============================================================
 * RESPONSIVE TABLE → CARDS
 * <td> braucht data-label="…"
 * ============================================================ */
@media (max-width: 767px) {
    .br-m-table-cards {
        border: 0;
        background: transparent;
    }
    .br-m-table-cards thead {
        position: absolute;
        left: -9999px;
    }
    .br-m-table-cards tr {
        display: block;
        margin-bottom: .75rem;
        background: var(--br-surface-card, #edeae0);
        border: 1px solid var(--br-border-soft, #e8e4da);
        border-radius: var(--br-radius, 10px);
        padding: .75rem 1rem;
    }
    .br-m-table-cards td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 1rem;
        padding: .35rem 0;
        border: none;
    }
    .br-m-table-cards td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--br-text-soft, #7a6a56);
        font-size: .85rem;
        flex: 0 0 40%;
    }
    .br-m-table-cards td:first-child {
        font-weight: 700;
        font-size: 1.05rem;
        color: var(--br-primary, #773E18);
        border-bottom: 1px solid var(--br-border-soft, #e8e4da);
        padding-bottom: .5rem;
        margin-bottom: .35rem;
        display: block;
    }
    .br-m-table-cards td:first-child::before {
        display: none;
    }
}

/* ============================================================
 * Body-Lock bei offenem Sheet/Drawer
 * ============================================================ */
body.br-m-no-scroll {
    overflow: hidden;
    touch-action: none;
}
