/* ============================================================
   LAYOUT
   Каркас приложения, шапка, навигация, страницы, поиск
   ============================================================ */

#app {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
}
#app.active { display: flex; }

/* Баннер уведомлений */
#notifBanner {
  background: var(--accent);
  padding: 12px;
  text-align: center;
  font-size: 14px;
  cursor: pointer;
  display: none;
  padding-top: calc(12px + env(safe-area-inset-top));
  align-items: center;
  justify-content: center;
  gap: 8px;
}
#notifBanner.show { display: flex; }
#notifBanner .icon { width: 18px; height: 18px; }

/* ============================================================
   ШАПКА
   ============================================================ */

header#mainHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-height: 56px;
}

.header-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.header-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

/* Онлайн-бейдж — кружок + цифра */
.online-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px 2px 4px;
  border-radius: 10px;
  background: rgba(58, 157, 93, 0.15);
  flex-shrink: 0;
}

.online-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3a9d5d;
  box-shadow: 0 0 0 2px rgba(58, 157, 93, 0.25);
}

.online-num {
  font-size: 12px;
  font-weight: 700;
  color: #3a9d5d;
  line-height: 1;
}

/* Строка со сменами */
.header-shift {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.2;
}

.header-shift .shift-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.header-shift .shift-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.header-shift .shift-icon svg {
  width: 12px;
  height: 12px;
  display: block;
}

.header-shift .shift-num {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Стрелка перехода смены — теперь SVG, яркая */
.header-shift .shift-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: var(--accent);
  flex-shrink: 0;
}

.header-shift .shift-arrow-svg {
  width: 12px;
  height: 12px;
  display: block;
  stroke: var(--accent);
}

/* Правый блок — 🎮 + профиль */
.header-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* Общие стили иконок в шапке */
header .icon-btn {
  cursor: pointer;
  font-size: 20px;
  padding: 6px 8px;
  user-select: none;
  color: var(--text);
  position: relative;
  border-radius: 50%;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  text-decoration: none;
  flex-shrink: 0;
}
header .icon-btn:active { background: var(--bg-tertiary); }
header .icon-btn .icon {
  width: 20px;
  height: 20px;
}

/* Профиль-аватарка */
header .profile-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 15px;
  background-size: cover;
  background-position: center;
  transition: transform 0.15s;
}
header .profile-btn:active { transform: scale(0.9); }

/* Кнопки внутри chatView/formularView/kbView */
#chatView > header,
#formularView > header,
#kbView > header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding-top: calc(14px + env(safe-area-inset-top));
}
#chatView > header .title,
#formularView > header .title,
#kbView > header .title {
  font-weight: bold;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#chatView > header .back,
#formularView > header .back,
#kbView > header .back {
  font-size: 24px;
  cursor: pointer;
  display: none;
  padding: 0 8px;
  user-select: none;
  color: var(--text);
}
#chatView > header .back.show,
#formularView > header .back.show,
#kbView > header .back.show { display: block; }
#chatView > header .status { font-size: 12px; color: var(--accent); }

/* ============================================================
   КОНТЕНТ
   ============================================================ */

#content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
}
.page {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.page.active { display: flex; }

/* ============================================================
   НИЖНЯЯ НАВИГАЦИЯ
   ============================================================ */

#bottomNav {
  display: flex;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  padding: 8px 4px 10px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 11px;
  border: none;
  background: none;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: color 0.15s;
}
.nav-btn.active { color: var(--accent); }
.nav-btn .icon {
  width: 22px;
  height: 22px;
  display: block;
}
.nav-btn .nav-badge {
  position: absolute;
  top: 4px;
  right: 22%;
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: bold;
}

/* ============================================================
   ПОИСК
   ============================================================ */

#searchBar {
  padding: 10px 12px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
#searchBar input {
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: 20px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-size: 15px;
}

.search-section-title {
  padding: 12px 16px 6px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
}
.search-msg {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.search-msg:active { background: var(--bg-tertiary); }
.search-msg .meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.search-msg .meta .icon {
  width: 12px;
  height: 12px;
}
.search-msg .text { font-size: 14px; }
.search-msg mark {
  background: var(--accent);
  color: #fff;
  padding: 0 2px;
  border-radius: 2px;
}

/* ============================================================
   ПЛАВАЮЩАЯ КНОПКА +
   ============================================================ */

.fab {
  position: absolute;
  right: 20px;
  bottom: 100px;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  border: none;
  cursor: pointer;
  z-index: 6;
  box-shadow: 0 4px 15px rgba(74,124,255,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ============================================================
   СТИЛИ ДЛЯ АДМИНКИ
   ============================================================ */

.admin-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.admin-section h4 {
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--text);
}
.admin-section input[type="text"] {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
  margin-bottom: 8px;
}
.admin-section button {
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
  width: 100%;
}

/* Адаптив для узких экранов */
@media (max-width: 380px) {
  .header-title { font-size: 14px; }
  .header-shift { font-size: 10px; }
  .header-shift .shift-icon svg { width: 11px; height: 11px; }
  .header-shift .shift-arrow-svg { width: 11px; height: 11px; }
  .online-badge { padding: 2px 6px 2px 3px; }
  .online-dot { width: 8px; height: 8px; }
  .online-num { font-size: 11px; }
}