/* ================================================================
   MOBILE.CSS — Полная адаптация для мобильных устройств
   Hotel Intelligence | Mobile-First
   ================================================================ */

/* ==================== БАЗОВЫЙ СБРОС ==================== */

* {
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 768px) {
  /* Запрещаем горизонтальный скролл на уровне html/body */
  html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
  }

  body {
    overflow-x: hidden;
  }

  /* Все изображения и видео — не шире контейнера */
  img, video, iframe {
    max-width: 100%;
    height: auto;
  }

  /* Безопасные min-width для кнопок и интерактивных элементов */
  input, select, textarea, button {
    max-width: 100%;
  }
}

/* ==================== HAMBURGER MENU (INDEX PAGE) ==================== */

.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  z-index: 10005;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s ease, opacity 0.3s ease;
  transform-origin: center;
}

.menu-toggle.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.menu-toggle.active span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.menu-toggle.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  nav {
    display: none !important;
    position: fixed !important;
    top: 60px;
    left: 0;
    right: 0;
    background: rgba(10, 14, 39, 0.98) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    flex-direction: column !important;
    padding: 0.75rem 1rem 1.25rem !important;
    gap: 0.25rem !important;
    z-index: 9999 !important;
    border-bottom: 1px solid var(--border) !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6) !important;
  }

  nav.active {
    display: flex !important;
  }

  nav a {
    padding: 0.75rem 1rem !important;
    border-radius: var(--radius-md) !important;
    font-size: 1rem !important;
    color: var(--text-muted) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    min-height: 48px !important;
    display: flex !important;
    align-items: center !important;
    white-space: nowrap !important;
  }

  nav a:last-child, nav a.btn {
    border-bottom: none !important;
    margin-top: 0.5rem !important;
  }

  nav .btn {
    width: 100% !important;
    justify-content: center !important;
    min-height: 48px !important;
  }
}

/* ==================== HEADER ==================== */

@media (max-width: 768px) {
  header {
    padding: 0.75rem 0 !important;
    min-height: 56px !important;
    /* Убедимся что z-index не перекрывает bottom nav */
    z-index: 9500 !important;
  }

  .header-content {
    padding: 0 1rem !important;
    gap: 0.625rem !important;
  }

  .logo {
    font-size: 1.15rem !important;
    gap: 0.375rem !important;
  }

  /* Хедер дашборда: уплотняем кнопки */
  .header-content nav {
    gap: 0.375rem !important;
  }

  .header-content nav a:not(.btn) {
    font-size: 0.8rem !important;
    padding: 0.2rem !important;
  }

  .header-content .btn-outline.btn-sm {
    padding: 0.4rem 0.7rem !important;
    font-size: 0.75rem !important;
    min-height: 34px !important;
  }

  .notifications-bell img {
    width: 24px !important;
    height: 24px !important;
  }

  /* Dropdown уведомлений — полная ширина минус отступы */
  .notifications-dropdown {
    right: 0 !important;
    left: auto !important;
    width: calc(100vw - 2rem) !important;
    max-width: 340px !important;
  }
}

/* ==================== DASHBOARD: SIDEBAR → BOTTOM NAV ==================== */

@media (max-width: 768px) {
  /* Однаколоночный грид — сайдбар переходит в bottom nav */
  .dashboard-container {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
    margin-top: 0 !important;
    overflow-x: hidden !important;
  }

  /* ─── Fixed bottom navigation bar ─── */
  .sidebar {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    height: 58px !important;
    border-radius: 0 !important;
    padding: 0 !important;
    z-index: 9000 !important;
    border-top: 1px solid rgba(71, 85, 105, 0.7) !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: none !important;
    background: rgba(15, 23, 42, 0.97) !important;
    display: flex !important;
    align-items: stretch !important;
    overflow: hidden !important;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
  }

  /* Скрываем заголовок «Меню» */
  .sidebar > h3 { display: none !important; }

  /* Горизонтальный flex-ряд пунктов */
  .sidebar-menu {
    display: flex !important;
    flex-direction: row !important;
    gap: 0 !important;
    width: 100% !important;
    overflow-x: auto !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: stretch !important;
    justify-content: space-around !important;
    height: 58px !important;
  }

  .sidebar-menu::-webkit-scrollbar { display: none !important; }

  .sidebar-menu li {
    flex: 1 !important;
    min-width: 44px !important;
    max-width: 80px !important;
    margin: 0 !important;
    display: flex !important;
    align-items: stretch !important;
  }

  .sidebar-menu a {
    flex-direction: column !important;
    gap: 2px !important;
    padding: 4px 2px !important;
    font-size: 0.55rem !important;
    text-align: center !important;
    border-radius: 0 !important;
    height: auto !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    white-space: normal !important;
    overflow: hidden !important;
    display: flex !important;
    color: var(--text-muted) !important;
    background: transparent !important;
    line-height: 1.2 !important;
    letter-spacing: -0.01em !important;
    transition: background 0.15s, color 0.15s !important;
  }

  .sidebar-menu a.active {
    background: rgba(99, 102, 241, 0.18) !important;
    color: var(--primary-light) !important;
    border-top: 2px solid var(--primary-light) !important;
  }

  /* Убираем левую полосу-индикатор в bottom nav */
  .sidebar-menu a::before,
  .sidebar-menu a.active::before { display: none !important; }

  .sidebar-menu a:hover {
    background: rgba(99, 102, 241, 0.1) !important;
    color: var(--text) !important;
  }

  .menu-icon {
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0 !important;
    margin-bottom: 1px !important;
  }

  /* ─── Dashboard content: full width, offset below header and above bottom nav ─── */
  .dashboard-content {
    padding: 1rem !important;
    min-height: auto !important;
    border-radius: var(--radius-md) !important;
    overflow-x: hidden !important;
    /* Отступ снизу — под bottom nav */
    margin-bottom: 58px !important;
  }

  /* Dashboard section: правильный top padding для fixed header (56px) */
  .section {
    /* НЕ трогаем индекс-страницу — только если body contains .sidebar */
    padding: 0 !important;
  }
}

/* Секция дашборда получает правильный top offset */
@media (max-width: 768px) {
  body:has(.sidebar) .section {
    padding-top: 64px !important;
    padding-bottom: 0 !important;
  }

  body:has(.sidebar) .container {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }
}

/* iPhone safe area (notch / home bar) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 768px) {
    .sidebar {
      height: calc(58px + env(safe-area-inset-bottom)) !important;
      padding-bottom: env(safe-area-inset-bottom) !important;
    }

    .dashboard-content {
      margin-bottom: calc(58px + env(safe-area-inset-bottom)) !important;
    }

    body:has(.sidebar) footer {
      padding-bottom: calc(58px + env(safe-area-inset-bottom) + 1.5rem) !important;
    }
  }
}

/* ==================== DASHBOARD OVERVIEW ==================== */

@media (max-width: 768px) {
  /* Приветственный блок */
  .dashboard-section > div:first-child h2 {
    font-size: 1.3rem !important;
    margin-bottom: 0.375rem !important;
  }

  /* Статистические карточки: 2-col на планшете */
  .dashboard-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.75rem !important;
    margin-bottom: 1.25rem !important;
  }

  .dashboard-card {
    padding: 0.875rem !important;
  }

  .dashboard-card h4 {
    font-size: 0.7rem !important;
    letter-spacing: 0.04em !important;
  }

  .dashboard-card .value {
    font-size: 1.625rem !important;
    line-height: 1.2 !important;
  }

  /* "Последние обновления" header row — стекуется */
  .dashboard-section h3 {
    font-size: 1.1rem !important;
    margin-bottom: 0.875rem !important;
  }

  /* Строка фильтра дат — стек на мобильном */
  #date-filter {
    min-width: 0 !important;
    width: 100% !important;
    font-size: 0.875rem !important;
  }
}

/* Маленькие телефоны (до 480px): одна колонка везде */
@media (max-width: 480px) {
  .dashboard-grid {
    grid-template-columns: 1fr !important;
    gap: 0.625rem !important;
  }

  .dashboard-card {
    padding: 1rem !important;
  }

  /* Date inputs: полная ширина, стекуются */
  #start-date,
  #end-date {
    width: 100% !important;
    min-width: 0 !important;
  }

  #custom-dates {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }

  /* Select периода — на всю ширину */
  #date-filter,
  #occupancy-period {
    width: 100% !important;
    min-width: 0 !important;
  }
}

/* ==================== OVERVIEW: FILTER ROW ==================== */

@media (max-width: 768px) {
  /* Строка «Последние обновления» + фильтр — стек */
  .overview-filter-row {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.625rem !important;
    margin-bottom: 1rem !important;
  }

  .overview-filter-controls {
    width: 100% !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
  }

  .overview-filter-controls label {
    display: none !important; /* «Период:» очевидно без лейбла */
  }

  #date-filter {
    min-width: 0 !important;
    width: 100% !important;
    font-size: 0.875rem !important;
  }

  /* Блок кастомных дат — стек вертикально */
  .custom-dates-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem !important;
    width: 100% !important;
  }

  .custom-date-input {
    width: 100% !important;
    min-width: 0 !important;
  }

  .custom-dates-row span {
    display: none !important; /* Убираем «—» разделитель */
  }

  .custom-dates-row .btn {
    width: 100% !important;
    justify-content: center !important;
  }
}

/* ==================== ПАНЕЛЬ МОНИТОРИНГА ==================== */

@media (max-width: 768px) {
  .monitoring-panel {
    padding: 1.125rem !important;
  }

  .monitoring-panel h3 {
    font-size: 1.05rem !important;
    margin-bottom: 0.375rem !important;
  }

  /* Grid 3-col (inline style) → 2-col через класс */
  .monitoring-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 0.75rem !important;
    align-items: end !important;
  }

  /* Кнопки — отдельная строка */
  .monitoring-grid > div:last-child {
    grid-column: 1 / -1 !important;
    display: flex !important;
    gap: 0.5rem !important;
  }

  .btn-monitoring-launch,
  .btn-monitoring-history {
    flex: 1 !important;
    min-width: 0 !important;
    font-size: 0.8rem !important;
    padding: 0.6rem 0.5rem !important;
    white-space: nowrap !important;
  }
}

@media (max-width: 400px) {
  .monitoring-grid {
    grid-template-columns: 1fr !important;
  }

  .monitoring-grid > div:last-child {
    grid-column: 1 !important;
    flex-direction: column !important;
  }

  .btn-monitoring-launch,
  .btn-monitoring-history {
    width: 100% !important;
    flex: none !important;
  }
}

/* ==================== СЕКЦИИ: INLINE GRID OVERRIDES ==================== */
/*
 * Переопределяем все inline 2-col grid-template-columns внутри секций дашборда.
 * Используем CSS attribute selector — работает с inline-стилями.
 */

@media (max-width: 600px) {
  /* Базовая стоимость */
  #base-price [style*="grid-template-columns: 1fr 1fr"],
  #base-price [style*="grid-template-columns: repeat(auto-fit"],
  /* Калькулятор рекламы */
  #ad-calculator [style*="grid-template-columns: 1fr 1fr"],
  #ad-calculator [style*="grid-template-columns: repeat(auto-fit"],
  /* Отчёты */
  #reports [style*="grid-template-columns: 1fr 1fr"],
  #reports [style*="grid-template-columns: repeat(3"],
  /* Обзор */
  #overview [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* ==================== ФОРМА ДОБАВЛЕНИЯ КОНКУРЕНТА ==================== */

@media (max-width: 768px) {
  /* Заголовок «Управление конкурентами» + кнопка сводки */
  .competitor-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
    margin-bottom: 1rem !important;
  }

  .competitor-header h2 {
    font-size: 1.3rem !important;
    margin: 0 !important;
  }

  .competitor-header .btn {
    width: 100% !important;
    justify-content: center !important;
  }

  /* 3-col поиск → 1 col */
  .search-form-grid {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }

  .form-card-compact summary {
    padding: 0.875rem 1rem !important;
    font-size: 0.9rem !important;
  }
}

/* ==================== ТАБЛИЦА КОНКУРЕНТОВ ==================== */

@media (max-width: 768px) {
  /* Bleed-to-edges горизонтальный скролл */
  .table-container {
    padding: 0.5rem !important;
    margin: 0 -1rem !important;
    width: calc(100% + 2rem) !important;
    border-radius: 0 !important;
    -webkit-overflow-scrolling: touch !important;
  }

  table {
    min-width: 520px !important;
  }

  th {
    padding: 0.625rem 0.5rem !important;
    font-size: 0.72rem !important;
    white-space: nowrap !important;
  }

  td {
    padding: 0.55rem 0.5rem !important;
    font-size: 0.78rem !important;
  }

  .btn-icon {
    width: 30px !important;
    height: 30px !important;
    font-size: 0.85rem !important;
    padding: 0 !important;
  }
}

/* ==================== МОДАЛЬНЫЕ ОКНА ==================== */

@media (max-width: 768px) {
  /* Competitor modal → bottom sheet */
  .competitor-modal {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .competitor-modal-content {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 90vh !important;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
    margin: 0 !important;
  }

  .competitor-modal-header {
    padding: 1.125rem 1.25rem !important;
    position: sticky !important;
    top: 0 !important;
  }

  .competitor-modal-header h2 {
    font-size: 1.1rem !important;
  }

  .competitor-modal-body {
    padding: 1.125rem 1.25rem !important;
  }

  /* Confirm modal */
  .confirm-modal-content {
    max-width: 90vw !important;
    width: 90% !important;
  }

  .confirm-modal-header,
  .confirm-modal-footer {
    padding: 1.125rem !important;
  }

  .confirm-modal-body {
    padding: 1.125rem !important;
  }

  .confirm-modal-footer {
    gap: 0.5rem !important;
  }

  .confirm-modal-footer .btn {
    flex: 1 !important;
    min-width: 0 !important;
    padding: 0.75rem !important;
  }
}

/* ==================== SUBSCRIPTION CARD ==================== */

@media (max-width: 768px) {
  .subscription-card {
    padding: 1.125rem !important;
    border-radius: var(--radius-md) !important;
  }

  .subscription-card h3 {
    font-size: 1rem !important;
    margin-bottom: 0.625rem !important;
  }

  .subscription-info {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.625rem !important;
    margin-top: 0.875rem !important;
  }

  .subscription-info-item {
    padding: 0.75rem !important;
  }

  .subscription-info-item label {
    font-size: 0.7rem !important;
  }

  .subscription-info-item .value {
    font-size: 0.95rem !important;
  }
}

@media (max-width: 480px) {
  .subscription-info {
    grid-template-columns: 1fr !important;
  }
}

/* ==================== BILLING / PRICING ==================== */

@media (max-width: 768px) {
  .pricing-grid-dashboard {
    grid-template-columns: 1fr !important;
    gap: 0.875rem !important;
  }

  .pricing-card-dashboard {
    min-height: auto !important;
  }

  .pricing-features-dashboard {
    min-height: auto !important;
  }

  /* Публичные pricing cards (index page) */
  .pricing-grid {
    grid-template-columns: 1fr !important;
    gap: 1.125rem !important;
  }

  .pricing-card.popular {
    transform: scale(1) !important;
  }

  .pricing-card:hover {
    transform: scale(1) translateY(-4px) !important;
  }
}

/* ==================== ФОРМЫ ==================== */

@media (max-width: 768px) {
  .form-card {
    padding: 1rem !important;
  }

  /* form-row 2-col → 1-col */
  .form-row-2 {
    grid-template-columns: 1fr !important;
  }
}

/* ==================== FOOTER ==================== */

@media (max-width: 768px) {
  footer {
    padding: 2rem 0 1.25rem !important;
    margin-top: 2rem !important;
  }

  .footer-content {
    grid-template-columns: 1fr 1fr !important;
    gap: 1.5rem 1.125rem !important;
    margin-bottom: 1.5rem !important;
  }

  .footer-section h4 {
    font-size: 0.875rem !important;
    margin-bottom: 0.625rem !important;
  }

  .footer-section li {
    margin-bottom: 0.375rem !important;
  }

  .footer-section a,
  .footer-section p {
    font-size: 0.8rem !important;
  }

  .footer-legal-entity {
    font-size: 0.75rem !important;
    line-height: 1.5 !important;
  }

  .footer-bottom {
    padding-top: 1.125rem !important;
    font-size: 0.775rem !important;
  }

  .footer-disclaimer {
    font-size: 0.75rem !important;
    line-height: 1.65 !important;
  }
}

@media (max-width: 480px) {
  .footer-content {
    grid-template-columns: 1fr !important;
    gap: 1.125rem !important;
  }

  footer {
    padding: 1.5rem 0 1rem !important;
    margin-top: 1.5rem !important;
  }
}

/* Footer на дашборде — нижний отступ под bottom nav */
@media (max-width: 768px) {
  body:has(.sidebar) footer {
    padding-bottom: calc(58px + 1.25rem) !important;
  }
}

/* ==================== HERO SECTION (INDEX PAGE) ==================== */

@media (max-width: 480px) {
  .hero {
    padding-top: 72px !important;
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  .hero h1 {
    font-size: 1.875rem !important;
    line-height: 1.15 !important;
  }

  .hero-subtitle {
    font-size: 0.9rem !important;
  }

  .hero-buttons {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .hero-buttons .btn {
    width: 100% !important;
    max-width: 100% !important;
    justify-content: center !important;
  }
}

/* ==================== INDEX PAGE SECTIONS ==================== */

@media (max-width: 768px) {
  .section {
    /* Глобально на мобильном уменьшаем отступы секций */
    padding: 3rem 0 !important;
  }

  .section-title {
    margin-bottom: 2rem !important;
  }

  .section-title h2 {
    font-size: 1.75rem !important;
  }

  .section-title p {
    font-size: 0.95rem !important;
  }

  .features-grid,
  .stats-grid,
  .testimonials-grid {
    gap: 1.125rem !important;
  }

  .feature-card,
  .stat-card,
  .testimonial-card {
    padding: 1.375rem !important;
  }

  .stat-number {
    font-size: 2rem !important;
  }
}

/* ─── НА ДАШБОРДЕ: перекрываем глобальный .section ─── */
@media (max-width: 768px) {
  body:has(.sidebar) .section {
    padding-top: 64px !important;  /* header height + small gap */
    padding-bottom: 0 !important;
  }
}

/* ==================== AUTH PAGES ==================== */

@media (max-width: 480px) {
  .auth-card {
    padding: 1.75rem 1.25rem !important;
    border-radius: var(--radius-lg) !important;
  }

  .auth-header h1 {
    font-size: 1.5rem !important;
  }
}

/* ==================== КНОПКИ РЕЖИМОВ ==================== */

@media (max-width: 768px) {
  .mode-btn {
    padding: 0.6rem 1rem !important;
    font-size: 0.85rem !important;
  }
}

/* ==================== ALERTS ==================== */

@media (max-width: 768px) {
  .alert {
    padding: 0.875rem !important;
    font-size: 0.875rem !important;
  }
}

/* ==================== EMPTY STATE ==================== */

@media (max-width: 768px) {
  .empty-state {
    padding: 2.5rem 1rem !important;
  }

  .empty-state-icon {
    width: 56px !important;
    height: 56px !important;
  }
}

/* ==================== CONTAINER ==================== */

@media (max-width: 768px) {
  .container {
    padding: 0 1rem !important;
    max-width: 100vw !important;
  }
}
