/* Общие правки мобильной версии и режима приложения (PWA). Подключается на всех страницах (_Layout). */

/* Название опции в конфигураторе (шаг 3) — переносится, а не обрезается */
textarea.option-name {
    resize: none;
    overflow: hidden;
    field-sizing: content;
    min-height: 0;
    line-height: 1.35;
    background-color: #e9ecef;
    cursor: default;
}

/* Сетка карточек (блог, статьи в конфигураторе): было жёстко 4 колонки по 250px — на телефоне уезжало вправо */
.grid-container {
    grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)) !important;
}

/* Поля ввода ≥ 16px: iOS иначе увеличивает страницу при фокусе */
@media (max-width: 767.98px) {
    :is(input.form-control, select.form-select, textarea.form-control,
    input[type="text"], input[type="email"], input[type="tel"], input[type="password"], input[type="search"]):not(.stepper-value):not(.js-count-tur-input):not(.count_input_controll) {
        font-size: max(16px, 1em);
    }
}

@media (max-width: 767.98px) {
    /* Шаг 3 конфигуратора: цена и «In den Warenkorb» закреплены внизу экрана */
    .finisher-back {
        width: 100%;
    }

    .finisher-buy {
        position: sticky;
        bottom: 0;
        z-index: 1020;
        width: calc(100% + 24px);
        margin: 0 -12px;
        padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
        background: #fff;
        box-shadow: 0 -6px 18px rgba(0, 0, 0, .10);
        flex-direction: row !important;
        flex-wrap: wrap;
        align-items: center !important;
        justify-content: space-between;
        gap: 4px 12px !important;
        text-align: start !important;
    }

    .finisher-buy .finisher-buy__price {
        order: 1;
        margin: 0 !important;
    }

    .finisher-buy .finisher-buy__price #Allcost {
        font-size: 1.6rem !important;
        text-align: start !important;
        width: auto;
        max-width: 11ch;
    }

    .finisher-buy .finisher-buy__price {
        flex: 0 0 auto;
    }

    .finisher-buy .finisher-buy__info {
        order: 2;
        flex: 1 1 0;
        min-width: 0;
        text-align: end;
        font-size: .75rem !important;
    }

    .finisher-buy .finisher-buy__info * {
        margin: 0 !important;
        text-align: end !important;
        font-size: inherit !important;
    }

    .finisher-buy .finisher-buy__action {
        order: 3;
        margin-top: 0 !important;
    }

    .finisher-buy #FinisherRight {
        margin-left: 0;
        width: 100%;
    }

    /* Кнопка WhatsApp не перекрывает закреплённые панели */
    body:has(.finisher-buy) .whatsapp-button {
        bottom: calc(130px + env(safe-area-inset-bottom, 0px));
    }

    .whatsapp-button {
        width: 52px;
        height: 52px;
        right: 14px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }

    /* Подвал: системы производителей в две колонки и плотнее — раньше занимал несколько экранов */
    .footer .row > div:nth-child(-n+4) {
        flex: 0 0 50%;
        max-width: 50%;
    }

    .footer .row > div:nth-child(-n+4) ul {
        margin-top: 8px !important;
        margin-left: 0 !important;
        padding-left: 0;
        font-size: .9rem;
    }

    .footer li {
        margin: 2px 0;
    }

    .footer .row > div:nth-child(-n+4) a {
        display: inline-block;
        padding: 4px 6px; /* больше площадь нажатия */
    }

    .footer h3 {
        font-size: 1.25rem;
    }

    .footer .row > div:nth-child(5) img {
        max-width: 100%;
        height: auto;
    }
}

/* ---------- Режим приложения (установлено на главный экран) ---------- */

/* Нижняя навигация показывается только в установленном приложении: там нет кнопки «Назад» браузера */
.app-tabbar {
    display: none;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
    html {
        -webkit-tap-highlight-color: transparent;
    }

    header {
        padding-top: env(safe-area-inset-top, 0px);
    }

    .app-tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1035;
        background: #fff;
        border-top: 1px solid #e5e7eb;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        box-shadow: 0 -4px 16px rgba(0, 0, 0, .06);
    }

    .app-tabbar a, .app-tabbar button {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 7px 2px 6px;
        border: 0;
        background: none;
        color: #6b7280;
        font-size: 11px !important; /* site.css задаёт кнопкам 14px bold */
        font-weight: 400;
        line-height: 1.1;
        text-decoration: none;
        position: relative;
    }

    .app-tabbar i {
        font-size: 20px;
    }

    .app-tabbar .is-active {
        color: #dc3545;
        font-weight: 600;
    }

    .app-tabbar__badge {
        position: absolute;
        top: 3px;
        left: calc(50% + 6px);
        min-width: 17px;
        height: 17px;
        padding: 0 4px;
        border-radius: 9px;
        background: #dc3545;
        color: #fff;
        font-size: 10px;
        line-height: 17px;
        font-weight: 700;
    }

    body {
        padding-bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    }

    /* Закреплённые панели и WhatsApp — над нижней навигацией */
    .finisher-buy {
        bottom: calc(58px + env(safe-area-inset-bottom, 0px));
    }

    .whatsapp-button {
        bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important;
    }

    body:has(.finisher-buy) .whatsapp-button {
        bottom: calc(190px + env(safe-area-inset-bottom, 0px)) !important;
    }

    #cookie-consent {
        bottom: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* Кнопка «App installieren» (меню) — видна только когда браузер разрешает установку */
.app-install[hidden] {
    display: none !important;
}

/* Сообщение «Keine Internetverbindung» */
.app-offline {
    position: fixed;
    left: 50%;
    top: calc(10px + env(safe-area-inset-top, 0px));
    transform: translateX(-50%);
    z-index: 2000;
    background: #1f2937;
    color: #fff;
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}
