/* ============================================================================
 * bottom-nav — плавающая нижняя навигационная панель (mobile dock).
 *
 * Стили СКОПИРОВАНЫ из docs.daddy.by (public/css/bottom-nav.css) и
 * live.daddy.by (themes/altum/assets/css/bottom-nav.css), адаптированы
 * под go.daddy.by (Sngine):
 *   • акцентный цвет — var(--main-btn, #743CFD) (кнопка .btn-main Sngine);
 *   • тёмная тема управляется классом body.night-mode (и атрибутом
 *     [data-bs-theme="dark"] на body), как в остальной теме Sngine;
 *   • кнопка «Панель управления» скрыта вне Telegram WebView
 *     (класс .is-hidden ставит JS из includes/bottom-nav.php).
 * ========================================================================== */

.bottom-nav {
    /* Локальные значения переменных для go.daddy.by (светлая тема) */
    --card-bg: #ffffff;
    --button-bg: #1271c9;
    --input-border: #e5e7eb;
    --text-muted: #6b7280;

    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(20px + max(12px, env(safe-area-inset-bottom)));
    z-index: 1000;
    display: flex;
    justify-content: center;
    pointer-events: none; /* only the pill catches events */
    padding: 0 12px;
    animation: bottom-nav-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

body.night-mode .bottom-nav,
body[data-bs-theme="dark"] .bottom-nav {
    --card-bg: #1c1f24;
    --button-bg: #1271c9;
    --input-border: #2e333a;
    --text-muted: #9ca3af;
}

.bottom-nav-pill {
    pointer-events: auto;
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    gap: 2px;
    width: 100%;
    max-width: 520px;
    padding: 4px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--card-bg) 82%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    backdrop-filter: saturate(180%) blur(22px);
    box-shadow:
        0 10px 30px -10px rgba(0, 0, 0, 0.35),
        0 2px 8px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    border: 1px solid color-mix(in srgb, var(--input-border) 70%, transparent);
    overflow: visible; /* tooltips may float above the dock */
    isolation: isolate;
}

/* Subtle gradient sheen across the dock */
.bottom-nav-pill::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.08) 0%,
        rgba(255, 255, 255, 0) 50%
    );
    pointer-events: none;
    z-index: 0;
}

/* Indicator kept in DOM for JS compat, but hidden in icon-only dock */
.bottom-nav-indicator {
    display: none;
}

/* Each tab wrapped in a flex cell so the tooltip can position relative to it */
.bottom-nav-item {
    position: relative;
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

/* Кнопка «Панель управления» вне Telegram WebView (JS ставит .is-hidden) */
.bottom-nav-item.is-hidden {
    display: none !important;
}

/* Base button — circular icon-only */
.bottom-nav-pill .nav-tab {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-muted, #8a8f9b);
    border-radius: 999px;
    padding: 0;
    transition:
        color 0.25s ease,
        background-color 0.25s ease,
        transform 0.25s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    font-family: inherit;
    outline: none;
    text-decoration: none;
}

.bottom-nav-pill .nav-tab:focus-visible {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--button-bg) 60%, transparent);
}

.bottom-nav-pill .nav-tab:active {
    transform: scale(0.92);
}

/* Hover — soft highlight on the icon */
.bottom-nav-pill .nav-tab:hover {
    color: color-mix(in srgb, var(--button-bg) 70%, #ffffff 30%);
    background-color: color-mix(in srgb, var(--button-bg) 14%, transparent);
}

.bottom-nav-pill .nav-tab:hover .nav-icon {
    transform: translateY(-1px) scale(1.06);
}

/* Active — pill-shaped gradient + white icon */
.bottom-nav-pill .nav-tab.active {
    color: #ffffff;
    background: linear-gradient(
        135deg,
        var(--button-bg) 0%,
        color-mix(in srgb, var(--button-bg) 70%, #ffffff 30%) 100%
    );
    box-shadow:
        0 6px 16px -4px color-mix(in srgb, var(--button-bg) 60%, transparent),
        inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.bottom-nav-pill .nav-tab.active .nav-icon {
    transform: translateY(-1px) scale(1.06);
}

/* Icon container — renders the SVG */
.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    line-height: 1;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.05));
}

.nav-icon svg {
    width: 24px;
    height: 24px;
    display: block;
}

/* Legacy font-awesome .fa inside .nav-icon — safety no-op for new markup */
.nav-icon .fa { display: block; }

/* Legacy .nav-label — kept harmless (empty span fallback) */
.nav-label {
    font-size: 10.5px;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.1;
    transition: font-weight 0.2s ease, letter-spacing 0.2s ease;
}

/* Tooltip above each tab — preline-style (HS) but pure CSS-driven */
.nav-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    font-size: 11.5px;
    line-height: 1;
    font-weight: 500;
    color: #ffffff;
    background: color-mix(in srgb, #000000 78%, transparent);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    padding: 6px 9px;
    border-radius: 8px;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.18s ease,
        transform 0.18s ease,
        visibility 0.18s ease;
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Tooltip arrow */
.nav-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: color-mix(in srgb, #000000 78%, transparent);
}

/* Show tooltip on hover, focus, or when item has .show class (Preline parity) */
.bottom-nav-item:hover .nav-tooltip,
.bottom-nav-pill .nav-tab:focus-visible ~ .nav-tooltip,
.bottom-nav-item.show .nav-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-2px);
}

@keyframes bottom-nav-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Reduced motion: keep functional look, drop animations */
@media (prefers-reduced-motion: reduce) {
    .bottom-nav,
    .bottom-nav-indicator,
    .nav-tab,
    .nav-icon,
    .nav-tooltip {
        transition: none !important;
        animation: none !important;
    }
}

/* ============================================================================
 * Модальное окно подтверждения перехода на главную find.daddy.by.
 *
 * Карточка + затемнение в стиле preline.co (см. preline.co/docs/overlay.html:
 * центрированная карточка rounded-xl, шапка с заголовком и крестиком,
 * body-текст, футер с кнопками secondary/primary). Разметка использует
 * собственные классы .bottom-nav-modal-* (Tailwind-утилит в теме нет),
 * акцент — те же переменные, что у док-панели (--button-bg и т.д.).
 *
 * Разметка/поведение — includes/bottom-nav.php, управление классом .open
 * делает инлайн-JS (клик по Dashboard открывает, затемнение/крестик/
 * «Отмена»/Esc закрывают, «Продолжить» — обычная ссылка).
 * ========================================================================== */

/* блокируем прокрутку фоновой страницы, пока окно открыто */
body.bottom-nav-modal-open {
    overflow: hidden;
}

.bottom-nav-modal {
    /* Локальные значения переменных для go.daddy.by (светлая тема) */
    --card-bg: #ffffff;
    --button-bg: #1271c9;
    --input-border: #e5e7eb;
    --text-muted: #6b7280;
    --text: #1f2937;

    position: fixed;
    inset: 0;
    z-index: 1200; /* выше док-панели (.bottom-nav, z-index 1000) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    visibility: hidden;
    pointer-events: none;
    transition: visibility 0s linear 0.25s; /* прячем после fade-out */
}

body.night-mode .bottom-nav-modal,
body[data-bs-theme="dark"] .bottom-nav-modal {
    --card-bg: #1c1f24;
    --button-bg: #1271c9;
    --input-border: #2e333a;
    --text-muted: #9ca3af;
    --text: #e5e7eb;
}

.bottom-nav-modal.open {
    visibility: visible;
    pointer-events: auto;
    transition: visibility 0s linear 0s;
}

/* Затемнение (backdrop) */
.bottom-nav-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.bottom-nav-modal.open .bottom-nav-modal-backdrop {
    opacity: 1;
}

/* Карточка (preline: sm:max-w-lg = 512px, rounded-xl) */
.bottom-nav-modal-panel {
    position: relative;
    width: 100%;
    max-width: 30rem;
    background: var(--card-bg);
    border: 1px solid color-mix(in srgb, var(--input-border) 80%, transparent);
    border-radius: 14px;
    box-shadow:
        0 24px 70px -20px rgba(0, 0, 0, 0.45),
        0 10px 30px -12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    transform: translateY(14px) scale(0.98);
    transition:
        opacity 0.25s ease,
        transform 0.25s cubic-bezier(0.3, 1.4, 0.6, 1);
    overflow: hidden;
    text-align: start;
}

.bottom-nav-modal.open .bottom-nav-modal-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Шапка: заголовок слева, крестик справа */
.bottom-nav-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid color-mix(in srgb, var(--input-border) 70%, transparent);
}

.bottom-nav-modal-title {
    margin: 0;
    font-size: 16px;
    line-height: 1.3;
    font-weight: 700;
    color: var(--text);
}

.bottom-nav-modal-close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 9999px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.bottom-nav-modal-close:hover {
    background: color-mix(in srgb, var(--text-muted) 14%, transparent);
    color: var(--text);
}

/* Текст сообщения */
.bottom-nav-modal-body {
    padding: 16px;
}

.bottom-nav-modal-text {
    margin: 0;
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--text);
}

/* Футер с кнопками */
.bottom-nav-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid color-mix(in srgb, var(--input-border) 70%, transparent);
}

.bottom-nav-modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.15s ease;
}

.bottom-nav-modal-btn:active {
    transform: translateY(1px);
}

/* «Продолжить» — primary (акцент док-панели) */
.bottom-nav-modal-btn-primary {
    color: #ffffff;
    background: var(--button-bg);
    box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--button-bg) 55%, transparent);
}

.bottom-nav-modal-btn-primary:hover {
    background: color-mix(in srgb, var(--button-bg) 85%, #000000 15%);
}

/* «Отмена» — secondary (нейтральная, с рамкой) */
.bottom-nav-modal-btn-secondary {
    color: var(--text);
    border-color: color-mix(in srgb, var(--input-border) 85%, transparent);
    background: color-mix(in srgb, var(--card-bg) 92%, #000000 8%);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.bottom-nav-modal-btn-secondary:hover {
    background: color-mix(in srgb, var(--input-border) 30%, var(--card-bg));
}

.bottom-nav-modal-close:focus-visible,
.bottom-nav-modal-btn:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--button-bg) 60%, transparent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .bottom-nav-modal,
    .bottom-nav-modal-backdrop,
    .bottom-nav-modal-panel,
    .bottom-nav-modal-close,
    .bottom-nav-modal-btn {
        transition: none !important;
    }
}
