/**
 * Mobile-first: навигация одной рукой, тапы ≥44px, safe area.
 * Не удаляет функциональность — перераспределяет UI для мобильных.
 */

/* Нижняя навигация (только на мобильных) */
.bottom-nav {
    display: none;
}

.categories-overlay {
    display: none;
}

@media (max-width: 768px) {
    /* Нижняя панель навигации */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 56px;
        padding-bottom: env(safe-area-inset-bottom, 0);
        background: var(--bg-color);
        border-top: 1px solid var(--border-color);
        z-index: 1000;
        align-items: center;
        justify-content: space-around;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-width: 44px;
        min-height: 44px;
        padding: 6px 12px;
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 0.6875rem;
        font-weight: 500;
        border: none;
        background: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        border-radius: var(--border-radius);
        flex: 1;
        max-width: 120px;
    }

    .bottom-nav-item:active {
        background: var(--bg-secondary);
    }

    .bottom-nav-item.active {
        color: var(--primary-color);
    }

    .bottom-nav-item svg {
        width: 24px;
        height: 24px;
        margin-bottom: 2px;
        flex-shrink: 0;
    }

    /* Контент не под панелью */
    .main-content {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0) + 1.5rem);
    }

    /* Оверлей категорий (full-screen) */
    .categories-overlay {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 1001;
        background: var(--bg-color);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        visibility: hidden;
        opacity: 0;
        transition: visibility 0.2s ease, opacity 0.2s ease;
    }

    .categories-overlay.is-open {
        visibility: visible;
        opacity: 1;
    }

    .categories-overlay-header {
        position: sticky;
        top: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1.25rem;
        background: var(--bg-color);
        border-bottom: 1px solid var(--border-color);
        z-index: 1;
    }

    .categories-overlay-title {
        font-size: 1.125rem;
        font-weight: 600;
        color: var(--text-color);
        margin: 0;
    }

    .categories-overlay-close {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        border: none;
        background: none;
        color: var(--text-secondary);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        border-radius: var(--border-radius);
    }

    .categories-overlay-close:active {
        background: var(--bg-secondary);
    }

    .categories-overlay-list {
        list-style: none;
        margin: 0;
        padding: 0.5rem 0 2rem;
    }

    .categories-overlay-list a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        min-height: 48px;
        padding: 12px 1.25rem;
        color: var(--text-color);
        text-decoration: none;
        font-weight: 500;
        -webkit-tap-highlight-color: transparent;
        border-bottom: 1px solid var(--border-color);
    }

    .categories-overlay-list a:active {
        background: var(--bg-secondary);
    }

    .categories-overlay-list a.active {
        color: var(--primary-color);
        background: rgba(37, 99, 235, 0.06);
    }

    .categories-overlay-list .category-count {
        font-size: 0.8125rem;
        color: var(--text-secondary);
        background: var(--bg-secondary);
        padding: 0.25rem 0.5rem;
        border-radius: 12px;
    }

    /* Верхняя шапка на мобильных — только логотип */
    .header .header-top {
        padding: 0.75rem 0;
    }

    .mobile-menu-toggle {
        display: none !important;
    }

    .main-nav {
        display: none !important;
    }

    /* Тапы не менее 44px */
    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-sm {
        min-height: 44px;
        padding: 0.75rem 1.25rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .service-input,
    .service-textarea,
    .service-select {
        min-height: 44px;
        font-size: 16px; /* предотвращает zoom на iOS при фокусе */
    }

    .service-input-wrapper label {
        margin-bottom: 0.5rem;
    }

    .service-tab-btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
        display: flex;
        align-items: center;
    }

    .category-card,
    .service-card,
    .popular-service-card {
        min-height: 44px;
    }

    .category-card a.btn,
    .service-card a.btn,
    .popular-service-card a.btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .category-card h2 a,
    .service-card h2 a,
    .popular-service-card h3 a {
        display: flex;
        align-items: center;
        padding: 0.25rem 0;
        min-height: 44px;
    }

    /* Кнопка копирования в полях */
    .service-copy-btn {
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
        right: 0.5rem;
    }

    /* Футер не перекрывать нижней навигацией — отступ уже у main */
    .footer {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    /* Контейнер — комфортные боковые отступы */
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Хлебные крошки — тап ≥44px */
    .breadcrumbs a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Читаемость и иерархия */
    .service-header h1 {
        font-size: 1.375rem;
        line-height: 1.3;
    }

    .page-header h1 {
        font-size: 1.375rem;
    }

    .hero-section h1 {
        font-size: 1.5rem;
    }
}

/* Safe area для устройств с вырезом */
@supports (padding: env(safe-area-inset-top)) {
    @media (max-width: 768px) {
        body {
            padding-left: env(safe-area-inset-left, 0);
            padding-right: env(safe-area-inset-right, 0);
        }
    }
}

/* Скелетон вместо спиннера (производительность, CLS) */
@media (max-width: 768px) {
    .skeleton {
        background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border-color) 50%, var(--bg-secondary) 75%);
        background-size: 200% 100%;
        animation: skeleton-shine 1.2s ease-in-out infinite;
        border-radius: var(--border-radius);
        min-height: 1.5rem;
    }
    @keyframes skeleton-shine {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }
}

/* Уведомления на мобильных — не перекрывать нижнюю панель */
@media (max-width: 768px) {
    .notification {
        bottom: calc(56px + env(safe-area-inset-bottom, 0) + 1rem);
        top: auto;
        left: 1rem;
        right: 1rem;
    }
}
