/* responsive.css: Мобильная адаптивность New Business Finder (:8350) - BUG-015 */

/* 1. Глобальный сброс переполнения и модели блоков */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  max-width: 100vw;
  overflow-x: hidden;
  position: relative;
}

/* 2. Адаптивная типографика (Fluid Typography) */
h1, .dashboard-title, .detail-title, .project-title {
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  line-height: 1.3;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
}

h2 {
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  line-height: 1.35;
  word-break: break-word;
  overflow-wrap: anywhere;
}

h3 {
  font-size: clamp(1.0rem, 3vw, 1.25rem);
  line-height: 1.4;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Стили заголовков дашборда и детальной страницы */
.dashboard-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}
.dashboard-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
}
.dashboard-actions, .detail-header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* 3. Горизонтальный инерционный скролл табов и фильтров */
.tabs-nav, .thoughts-filter-bar, .status-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  max-width: 100%;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 4px;
}
.tabs-nav::-webkit-scrollbar,
.thoughts-filter-bar::-webkit-scrollbar,
.status-pills::-webkit-scrollbar {
  display: none;
}
.tab-btn, .tabs-nav .tab-btn, .status-pills .pill {
  flex-shrink: 0;
  white-space: nowrap;
}

/* 4. Изоляция таблиц и блоков кода от распирания вьюпорта */
.doc-card table, .table-container, table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
}
pre, code {
  max-width: 100%;
  overflow-x: auto;
  word-break: break-all;
}
.doc-card pre {
  word-break: normal;
  white-space: pre;
}

/* 5. Медиа-запрос: Планшеты и смартфоны (<= 768px) */
@media (max-width: 768px) {
  .container {
    padding: 0 16px;
  }
  .nav-content {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 10px 16px;
  }
  .brand {
    justify-content: space-between;
  }
  .user-menu {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }
  .user-info {
    align-items: flex-start;
  }
  .user-email {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.82rem;
  }
  .dashboard-header, .dashboard-header-bar, .project-header, .detail-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .header-actions, .dashboard-actions, .project-actions, .detail-header-actions {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }
  .btn, .btn-primary, .btn-secondary, .btn-ai-generate, .btn-propose, .btn-share {
    width: 100%;
    justify-content: center;
    min-height: 42px;
    text-align: center;
  }
  .projects-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .search-form, .search-input {
    width: 100%;
    min-width: 0;
  }
  .decision-actions {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }
  .decision-actions .btn-decision {
    width: 100%;
    justify-content: center;
    min-height: 42px;
  }
  input[type="text"], input[type="search"], input[type="email"], input[type="password"], textarea, select {
    font-size: 16px !important;
  }
}

/* 6. Медиа-запрос: Мобильные устройства (<= 480px) */
@media (max-width: 480px) {
  .container {
    padding: 0 12px;
  }
  .user-email {
    max-width: 140px;
  }
  .btn-logout, .user-menu .btn-secondary, .user-menu .btn-primary {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
  }
  .modal-content, .glass-modal, .modal-window {
    width: 95% !important;
    max-width: 95vw !important;
    margin: 10px auto !important;
    padding: 16px !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
  }
  .stages-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  .doc-card {
    padding: 16px 12px;
  }
}

/* 7. Медиа-запрос: Сверхмалые дисплеи (<= 360px) */
@media (max-width: 360px) {
  .container {
    padding: 8px 12px;
  }
  .user-email {
    max-width: 110px;
    font-size: 0.75rem;
  }
  .stages-grid {
    grid-template-columns: 1fr !important;
  }
  .dashboard-title, .detail-title {
    font-size: 1.15rem;
  }
  .kpi-card {
    padding: 12px;
  }
  .kpi-value {
    font-size: 20px;
  }
}
