/**
 * Mobile-first: нижняя навигация, touch-targets 44px, панель фильтров
 */

/* Убираем горизонтальный скролл на мобильных */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }
  #root {
    max-width: 100%;
    overflow-x: hidden;
  }
  main {
    max-width: 100%;
    min-width: 0;
  }
}

/* Нижняя навигация — только до 768px, всегда поверх контента */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100vw;
    height: 56px;
    min-height: 56px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: #1e3c72;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    align-items: center;
    justify-content: space-around;
  }

  .mobile-bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 6px 8px;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    transition: color 0.2s, background 0.2s;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-bottom-nav a:hover,
  .mobile-bottom-nav a:focus {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
  }

  .mobile-bottom-nav a i {
    font-size: 22px;
    margin-bottom: 2px;
  }

  /* Отступ у контента, чтобы не перекрывался нижней панелью */
  body.has-mobile-nav main {
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0) + 24px);
  }

  body.has-mobile-nav footer {
    margin-bottom: calc(56px + env(safe-area-inset-bottom, 0));
  }
}

/* Touch-targets не менее 44×44 px для кнопок и кликабельных элементов */
@media (max-width: 768px) {
  .mobile-bottom-nav a,
  .filter-toggle-btn,
  .view-toggle-btn,
  button.view-toggle-btn,
  #openFiltersBtn,
  #resetFiltersBtn,
  .profile-btn,
  .pagination-btn,
  #headerBurger,
  #headerNavClose {
    min-width: 44px;
    min-height: 44px;
  }

  .filter-toggle-wrap {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .view-toggle-btn,
  button.view-toggle-btn {
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  #searchForm button[type="submit"] {
    min-height: 48px;
  }

  #openFiltersBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 16px;
    font-weight: 500;
    border-radius: 8px;
    border: 2px solid #1e3c72;
    background: #fff;
    color: #1e3c72;
  }

  #openFiltersBtn.is-open {
    background: #1e3c72;
    color: #fff;
  }

  /* Ограничение ширины: поиск и блок результатов не выходят за экран */
  #searchBlock .max-w-6xl,
  #searchBlock .bg-white {
    max-width: 100%;
  }
  #searchWrap {
    min-width: 0;
  }
  #searchForm .flex-col > div {
    min-width: 0;
  }
  #searchInput {
    min-width: 0;
    max-width: 100%;
  }
  /* Строка с сортировкой и кнопками вида */
  #resultsTitle ~ * .flex-wrap,
  .py-16.bg-gray-50 .flex-wrap {
    max-width: 100%;
  }
  #filterSort {
    max-width: 100%;
    min-width: 0;
  }
  /* Блок «Найдено юристов» + сортировка */
  section.py-16.bg-gray-50 .max-w-7xl {
    max-width: 100%;
  }
  section.py-16.bg-gray-50 .flex.flex-wrap {
    min-width: 0;
  }
}

/* На главной: панель фильтров на мобильных — скрыта по умолчанию, открывается по кнопке */
@media (max-width: 768px) {
  .mobile-filters-wrap {
    position: relative;
  }

  .mobile-filters-toggle-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
  }

  #filtersPanel {
    display: none;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
  }

  #filtersPanel.is-open {
    display: block;
  }
}

@media (min-width: 769px) {
  .mobile-filters-toggle-row {
    display: none;
  }

  #filtersPanel {
    display: block !important;
  }

  .reset-filters-mobile {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .reset-filters-desktop {
    display: none !important;
  }
}

/* Skeleton при загрузке списка */
.results-skeleton {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .results-skeleton {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .results-skeleton {
    grid-template-columns: repeat(4, 1fr);
  }
}

.skeleton-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.skeleton-card .skeleton-image {
  width: 100%;
  height: 180px;
  background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.2s ease-in-out infinite;
}

.skeleton-card .skeleton-body {
  padding: 16px;
}

.skeleton-card .skeleton-line {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, #e5e7eb 25%, #f3f4f6 50%, #e5e7eb 75%);
  background-size: 200% 100%;
  animation: skeleton-shine 1.2s ease-in-out infinite;
  margin-bottom: 10px;
}

.skeleton-card .skeleton-line:last-child {
  margin-bottom: 0;
  width: 60%;
}

@keyframes skeleton-shine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
