/* security: CSP style-src 'self' запрещает inline-стили ('unsafe-inline'
   убран). Ранее эти правила были <style> в index.html и атрибутами style=...
   на bootstrap-элементах; вынесены во внешний файл, загружается до body. */

/* Мгновенный цвет фона без мигания (FOUC) */
html,
body.boot-body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background-color: #f5f7fb !important;
  color: #0b1526;
}

/* Общие контейнеры индикатора загрузки / ошибки */
.boot-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, sans-serif;
  text-align: center;
  padding: 1rem;
}

.boot-text-muted {
  color: #5b6b82;
}

.boot-text-ink {
  color: #0b1526;
}

.boot-hidden {
  display: none !important;
}

.boot-visible {
  display: flex !important;
}

.boot-error-box {
  max-width: 480px;
}

.boot-error-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 0.5rem;
}

.boot-error-detail {
  font-size: 0.85rem;
  color: #5b6b82;
  margin: 0 0 1rem;
  word-break: break-word;
}

.boot-button {
  padding: 0.5rem 1.25rem;
  border-radius: 0.5rem;
  border: none;
  background: #2563eb;
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}

/* Поле «Описание проблемы» в форме обращения: высота ограничена настройками
   сервера (TICKET_TEXTAREA_MIN/MAX_ROWS), они приходят из API (/api/tickets).
   security: вместо inline style={} (запрещён CSP style-src 'self') значения
   подставляются в CSS custom properties через ref; сам класс — внешний ресурс. */
.ticket-desc-textarea {
  min-height: calc(var(--ticket-min-rows, 5) * 1.25rem + 1rem);
  max-height: calc(var(--ticket-max-rows, 20) * 1.25rem + 1rem);
}

/* Мобильная шапка DashboardPage и общего PageHeader.
   Действия и portal-слоты остаются в DOM; не скрываем переполнение. */
@media (max-width: 639px) {
  body header > .max-w-6xl {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    height: auto;
    min-height: 64px;
    column-gap: 8px;
    row-gap: 8px;
    padding: 10px 12px;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
  }

  body header > .max-w-6xl > :first-child {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  /* DashboardPage: меню с ml-6/mr-auto переносится на второй ряд. */
  body header > .max-w-6xl > .mr-auto.flex {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    margin: 0;
    min-width: 0;
    max-width: 100%;
  }

  /* PageHeader: Brand и слот чата становятся элементами общей сетки. */
  body header > .max-w-6xl:not(:has(> .mr-auto.flex)) > div:first-child {
    display: contents;
  }

  body header > .max-w-6xl:not(:has(> .mr-auto.flex)) > div:first-child > div:first-child {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  body header [data-support-chat-slot] {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  body header > .max-w-6xl > div:last-child {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    gap: 6px;
  }

  body header .leading-tight {
    min-width: 0;
  }

  body header .leading-tight > p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body header .w-12.h-12 {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }

  body header > .max-w-6xl button,
  body header > .max-w-6xl a {
    min-height: 40px;
    box-sizing: border-box;
    flex-shrink: 0;
  }
}

/* Only the browser-notification switch, never the Internet switch. */
@media (max-width: 639px) {
  body header [data-browser-notifications-slot] > button[role='switch'] {
    min-height: 44px;
    gap: 6px;
    padding: 6px 8px;
    transition: background-color 150ms, border-color 150ms;
  }

  body header [data-browser-notifications-slot] > button[role='switch']::before {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    background: url('/notification-bell-off.svg') center / contain no-repeat;
  }

  body header [data-browser-notifications-slot] > button[role='switch'][aria-checked='true'] {
    background-color: #ecfdf5;
    border-color: #a7f3d0;
  }

  body header [data-browser-notifications-slot] > button[role='switch'][aria-checked='true']::before {
    background-image: url('/notification-bell.svg');
  }

  body header [data-browser-notifications-slot] > button[role='switch']:enabled:hover {
    border-color: #94a3b8;
  }

  body header [data-browser-notifications-slot] > button[role='switch'][aria-checked='true']:enabled:hover {
    background-color: #d1fae5;
    border-color: #6ee7b7;
  }
}

@media (max-width: 639px) and (prefers-reduced-motion: reduce) {
  body header [data-browser-notifications-slot] > button[role='switch'] {
    transition: none;
  }
}
