/**
 * SCHUV v2 — общая адаптивность (портал и сервисы).
 * Подключать после Bootstrap. Сайдбар на малых экранах — через offcanvas (разметка в шаблонах).
 */

:root {
  --schuv-content-padding-x: clamp(0.75rem, 2.5vw, 2rem);
  --schuv-content-padding-y: clamp(0.65rem, 1.5vw, 1.5rem);
}

html {
  overflow-x: hidden;
}

.schuv-layout,
.ref-layout,
.app-layout.schuv-layout {
  min-width: 0;
}

/* Фон сайдбара — в schuv-portal-shell.css (PPE gradient) */

.schuv-content,
.ref-content,
.content-wrapper {
  min-width: 0;
}

/* Переопределение крупных отступов из локальных стилей */
.schuv-content,
.ref-content {
  padding-left: var(--schuv-content-padding-x) !important;
  padding-right: var(--schuv-content-padding-x) !important;
  padding-top: var(--schuv-content-padding-y) !important;
  padding-bottom: var(--schuv-content-padding-y) !important;
}

@media (max-width: 991.98px) {
  .schuv-layout,
  .ref-layout {
    flex-direction: column;
    align-items: stretch;
  }

  .schuv-layout > main,
  .ref-layout > main {
    width: 100%;
  }

  .ref-filter-form {
    flex-wrap: wrap !important;
  }

  .ref-filter-form .ts-wrapper {
    max-width: 100% !important;
    flex: 1 1 12rem;
  }
}

@media (max-width: 575.98px) {
  .ref-filter-form .ts-wrapper {
    flex-basis: 100%;
  }
}

/* Таблицы: прокрутка без поломки карточки / overflow страницы */
.schuv-table-scroll,
.schuv-content .table-responsive,
.card-body > .table-responsive {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.schuv-content .table-responsive > table,
.card-body > .table-responsive > table {
  margin-bottom: 0;
}

/* Подсказка горизонтального скролла (опционально в разметке) */
.schuv-scroll-hint--mobile {
  display: none !important;
}

@media (max-width: 991.98px) {
  .schuv-scroll-hint--desktop {
    display: none !important;
  }

  .schuv-scroll-hint--mobile {
    display: inline !important;
  }

  .schuv-scroll-hint-block.schuv-scroll-hint--mobile {
    display: block !important;
  }
}

/* Плитки каталога / виджеты — явные breakpoints (task-019) */
.schuv-widgets-grid,
.schuv-catalog-grid {
  display: grid;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.schuv-widgets-grid {
  gap: 1rem;
  grid-template-columns: 1fr;
}

.schuv-catalog-grid {
  gap: clamp(0.75rem, 2vw, 1.5rem);
  grid-template-columns: 1fr;
}

.schuv-catalog-card,
.schuv-widget-card {
  min-width: 0;
  max-width: 100%;
}

.schuv-catalog-card .card-text,
.schuv-widget-card .card-body {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (min-width: 576px) {
  .schuv-widgets-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .schuv-catalog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .schuv-widgets-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .schuv-catalog-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1200px) {
  .schuv-widgets-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .schuv-catalog-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.breadcrumb {
  min-width: 0;
  flex: 1 1 auto;
}

.navbar-brand {
  max-width: min(100%, 52vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 575.98px) {
  .navbar .dropdown-menu {
    max-width: calc(100vw - 1rem);
  }

  .schuv-portal-shell .schuv-content h2 {
    font-size: clamp(1.15rem, 5vw, 1.5rem);
  }

  .schuv-catalog-card .card-title {
    font-size: 1rem;
  }
}

@media (max-width: 991.98px) {
  .schuv-portal-shell .schuv-layout {
    flex-direction: column;
  }

  .schuv-portal-shell .schuv-layout > main.schuv-content {
    width: 100%;
    max-width: 100%;
  }
}

/* Attendance: сайдбар в колонку на узком экране */
@media (max-width: 991.98px) {
  .app-layout.schuv-layout:not(.no-sidebar) {
    flex-direction: column;
  }

  .app-layout.schuv-layout:not(.no-sidebar) .sidebar.schuv-sidebar {
    width: 100% !important;
    max-height: min(48vh, 22rem);
    overflow-y: auto;
    flex-shrink: 0;
    order: 0;
  }
}
