/* ==========================================================================
   BARKOL PWA MOBILE APP EXPERIENCE STYLES
   Адаптивные стили интерфейса мобильного приложения (App-like UI)
   ========================================================================== */

/* Скрытие мобильных элементов на десктопе (экраны > 768px) */
@media (min-width: 769px) {
    .mobile-bottom-bar,
    .mobile-fab,
    .mobile-bottom-sheet,
    .mobile-app-header-btn {
        display: none !important;
    }
}

/* Стили интерфейса для мобильных экранов (<= 768px) */
@media (max-width: 768px) {
    /* Скрытие десктопного блока header-right на мобильных (перенесен в шторку и bottom bar) */
    header.header .header-right {
        display: none !important;
    }

    /* Мобильная кнопка аватара в шапке (внутри .logo-container) */
    .mobile-header-avatar-btn {
        position: absolute;
        right: 55px;
        top: 13px;
        width: 34px;
        height: 34px;
        padding: 0;
        border: none;
        background: transparent;
        cursor: pointer;
        z-index: 100;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-header-avatar-btn img {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        object-fit: cover;
        border: 2px solid #0088cc;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
        transition: transform 0.15s ease;
    }

    .mobile-header-avatar-btn:active img {
        transform: scale(0.92);
    }

    /* Нижний отступ для страницы, чтобы контент не перекрывался Bottom Bar */
    body {
        padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .content-body {
        padding-bottom: 20px !important;
    }

    /* Фиксированная нижняя панель навигации (Bottom Navigation Bar) */
    .mobile-bottom-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(56px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #002b49;
        border-top: 1px solid rgba(255, 255, 255, 0.12);
        box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.25);
        z-index: 1045;
        display: flex;
        align-items: center;
        justify-content: space-around;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        flex: 1;
        height: 54px;
        color: #94a3b8;
        text-decoration: none;
        font-size: 10px;
        font-weight: 600;
        letter-spacing: 0.2px;
        position: relative;
        transition: color 0.2s ease, transform 0.15s ease;
        -webkit-tap-highlight-color: transparent;
        border: none;
        background: transparent;
        padding: 0;
        cursor: pointer;
        user-select: none;
        -webkit-user-select: none;
    }

    /* Все дочерние элементы иконки и текста пропускают клик на саму кнопку */
    .mobile-nav-item * {
        pointer-events: none !important;
    }

    .mobile-nav-item:active {
        transform: scale(0.92);
    }

    .mobile-nav-item i {
        font-size: 20px;
        margin-bottom: 2px;
        transition: transform 0.2s ease;
    }

    /* Полное отключение мешающих перекрывающих элементов в правом нижнем углу */
    .scroll-to-top,
    html .scroll-to-top,
    html.modern .scroll-to-top {
        display: none !important;
        pointer-events: none !important;
        visibility: hidden !important;
    }

    #toastAreaCenter {
        pointer-events: none !important;
    }

    #toastAreaCenter .toast {
        pointer-events: auto !important;
    }

    .mobile-nav-item.active {
        color: #38bdf8 !important;
    }

    .mobile-nav-item.active::after {
        content: '';
        position: absolute;
        bottom: 3px;
        width: 4px;
        height: 4px;
        background-color: #38bdf8;
        border-radius: 50%;
        box-shadow: 0 0 8px #38bdf8;
    }

    /* Бейдж непрочитанных уведомлений на кнопке */
    .mobile-nav-badge {
        position: absolute;
        top: 5px;
        right: calc(50% - 16px);
        min-width: 16px;
        height: 16px;
        padding: 0 4px;
        font-size: 9px;
        font-weight: 700;
        line-height: 16px;
        text-align: center;
        background-color: #ef4444;
        color: #ffffff;
        border-radius: 8px;
        border: 1.5px solid #002b49;
    }

    /* Плавающая кнопка быстрого действия (FAB — Floating Action Button) */
    .mobile-fab {
        position: fixed;
        right: 16px;
        bottom: calc(68px + env(safe-area-inset-bottom, 0px));
        width: 46px;
        height: 46px;
        border-radius: 50%;
        background: linear-gradient(135deg, #0284c7 0%, #002b49 100%);
        color: #ffffff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 22px;
        border: 2px solid #ffffff;
        box-shadow: 0 4px 16px rgba(2, 132, 199, 0.45);
        z-index: 1035;
        cursor: pointer;
        transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        text-decoration: none;
    }

    .mobile-fab:active {
        transform: scale(0.9);
        color: #ffffff;
    }

    /* Мобильные модальные окна и шторки быстрых действий (Modals & Bottom Sheets) */
    .modal {
        z-index: 10500 !important;
    }

    .modal.mobile-bottom-sheet {
        z-index: 10500 !important;
        padding: 0 !important;
        background: transparent !important;
    }

    .modal-backdrop {
        z-index: 10400 !important;
    }

    .modal.mobile-bottom-sheet .modal-dialog {
        margin: 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        transform: translateY(100%) !important;
        transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1) !important;
        z-index: 10505 !important;
        pointer-events: auto !important;
    }

    .modal.mobile-bottom-sheet.show .modal-dialog,
    .modal.mobile-bottom-sheet.fade.show .modal-dialog {
        transform: translateY(0) !important;
    }

    .modal.mobile-bottom-sheet .modal-content {
        border-radius: 20px 20px 0 0 !important;
        border: none !important;
        box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35) !important;
        background: #ffffff !important;
        padding-bottom: max(20px, env(safe-area-inset-bottom, 0px)) !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
    }

    .bottom-sheet-handle {
        width: 38px;
        height: 4px;
        background-color: #cbd5e1;
        border-radius: 2px;
        margin: 10px auto 14px auto;
    }

    .quick-action-btn {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        border-radius: 10px;
        background-color: #f8fafc;
        border: 1px solid #e2e8f0;
        color: #1e293b;
        text-decoration: none;
        font-weight: 600;
        font-size: 0.9rem;
        transition: background-color 0.15s ease, transform 0.15s ease;
        width: 100%;
        margin-bottom: 8px;
    }

    .quick-action-btn:active {
        background-color: #e2e8f0;
        transform: scale(0.98);
        color: #0284c7;
    }

    .quick-action-icon {
        width: 38px;
        height: 38px;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 20px;
        flex-shrink: 0;
    }

    /* Баннер установки PWA на рабочий стол */
    .pwa-install-banner {
        position: fixed;
        top: -120px;
        left: 12px;
        right: 12px;
        background: linear-gradient(135deg, #002b49 0%, #001e33 100%);
        border: 1px solid rgba(56, 189, 248, 0.35);
        border-radius: 14px;
        padding: 10px 14px;
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
        z-index: 99999;
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), top 0.4s ease;
    }

    .pwa-install-banner.show {
        top: calc(12px + env(safe-area-inset-top, 0px));
    }

    .pwa-banner-content {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .pwa-banner-icon {
        width: 36px;
        height: 36px;
        border-radius: 8px;
        flex-shrink: 0;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    }

    .pwa-banner-text {
        flex: 1;
        min-width: 0;
    }

    .pwa-banner-title {
        font-size: 13px;
        font-weight: 700;
        color: #ffffff;
        line-height: 1.2;
    }

    .pwa-banner-subtitle {
        font-size: 11px;
        color: #94a3b8;
        line-height: 1.2;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .pwa-banner-actions {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }

    .pwa-btn-install {
        padding: 5px 12px;
        font-size: 12px;
        font-weight: 600;
        border-radius: 6px;
        background-color: #0284c7;
        border-color: #0284c7;
        color: #ffffff;
    }

    .pwa-btn-install:hover, .pwa-btn-install:active {
        background-color: #0369a1;
        border-color: #0369a1;
    }

    .pwa-btn-close {
        font-size: 10px;
        opacity: 0.7;
        filter: invert(1) grayscale(100%) brightness(200%);
    }

    /* Сенсорная оптимизация и тактильный отклик (Touch UX) */
    button, .btn, a.nav-link, .mobile-nav-item, .quick-action-btn, .pagination .page-link {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .btn:active, .card-body .btn:active, .quick-action-btn:active {
        transform: scale(0.97);
        transition: transform 0.1s ease;
    }

    /* Предотвращение нежелательного зума на iOS/Android при фокусе в поля ввода */
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    input[type="date"],
    select.form-control,
    select.form-select,
    textarea.form-control {
        font-size: 16px !important;
    }

    /* Плавная нативная анимация появления страниц */
    .content-body {
        animation: mobilePageFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    }

    @keyframes mobilePageFadeIn {
        from {
            opacity: 0.85;
            transform: translateY(4px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Индикатор Pull-to-Refresh */
    .pull-to-refresh-indicator {
        position: fixed;
        top: -60px;
        left: 50%;
        transform: translateX(-50%);
        width: 38px;
        height: 38px;
        background: #002b49;
        border: 2px solid #38bdf8;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #38bdf8;
        font-size: 20px;
        z-index: 99999;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
        transition: top 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s ease, opacity 0.2s ease;
        opacity: 0;
        pointer-events: none;
    }

    .pull-to-refresh-indicator.refreshing {
        animation: ptrSpin 0.75s linear infinite;
    }

    @keyframes ptrSpin {
        100% { transform: translateX(-50%) rotate(360deg); }
    }
}

/* ============================================
   СКРЫТИЕ МОБИЛЬНЫХ ЭЛЕМЕНТОВ ПРИ ПЕЧАТИ
============================================ */
@media print {
    .mobile-bottom-bar,
    .mobile-fab,
    .modal.mobile-bottom-sheet,
    .modal-backdrop,
    .pull-to-refresh-indicator {
        display: none !important;
        visibility: hidden !important;
    }
}

