/* Базовая тема по умолчанию (eQ Dark Tech Theme) */
:root {
  --company-title: "eQ";
  --company-subtitle: "Электронная Очередь";
  --primary-color: #3b82f6; /* яркий синий */
  --accent-color: #60a5fa;
  --bg-color: #0f172a; /* ультра темный синий-серый */
  --card-color: #1e293b; /* светлее для карточек */
  --text-color: #f8fafc;
  --text-muted-color: #94a3b8;
  --called-color: #f59e0b; /* янтарный для вызываемого билета */
  --serving-color: #10b981; /* зеленый изумрудный */
  --waiting-color: #06b6d4; /* cyan */
  --warning-color: #ef4444; /* красный для оффлайна */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  height: 100vh;
  overflow: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Холст табло: всегда 1920×1080, под экран подгоняется через transform:
   scale() в fitBoard() (display.js). Совместимость со старыми TV-движками
   (Tizen / Android TV WebView, Chrome >= 63): во вёрстке холста не используем
   flex-gap, aspect-ratio, inset, clamp(), container queries. */
#board {
  position: absolute;
  top: 0;
  left: 0;
  width: 1920px;
  height: 1080px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: 0 0;
}

/* Красная полоса предупреждения о небезопасном соединении HTTPS */
#https-warning-bar {
  background-color: #dc2626;
  color: #ffffff;
  text-align: center;
  padding: 8px 16px;
  font-size: 1.1rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  z-index: 100;
  display: none; /* Контролируется через JS */
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

/* Шапка приложения (Header) */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  background-color: rgba(30, 41, 59, 0.4);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.brand-section {
  display: flex;
  align-items: center;
}

.brand-logo-img {
  margin-right: 20px;
  max-height: 50px;
  max-width: 150px;
  object-fit: contain;
}

.brand-info h1 {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(to right, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.brand-info p {
  font-size: 1.1rem;
  color: var(--text-muted-color);
}

.status-section {
  display: flex;
  align-items: center;
}

.clock-display {
  font-size: 2.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
  margin-right: 25px;
}

.conn-status {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 1rem;
  font-weight: 600;
  background-color: rgba(255, 255, 255, 0.05);
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 10px;
  box-shadow: 0 0 8px currentColor;
}

.conn-status.online {
  color: #10b981;
}

.conn-status.offline {
  color: var(--warning-color);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* Основная сетка табло (16:9 Grid) */
.display-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  grid-template-rows: minmax(0, 1fr);
  grid-gap: 24px;
  padding: 24px 40px 40px 40px;
}

/* Левая секция: Главный вызов (Active Call) */
.active-call-area {
  display: flex;
  flex-direction: column;
  background-color: var(--card-color);
  border-radius: 24px;
  padding: 40px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

.active-call-area::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: linear-gradient(to bottom, var(--called-color), var(--primary-color));
}

.area-title {
  font-size: 1.3rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted-color);
  margin-bottom: 20px;
}

.active-call-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.active-ticket-num {
  font-size: 10rem;
  font-weight: 900;
  color: var(--called-color);
  line-height: 1;
  letter-spacing: -2px;
  margin-bottom: 20px;
  text-shadow: 0 0 40px rgba(245, 158, 11, 0.2);
  animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.active-window-label {
  font-size: 5rem;
  font-weight: 800;
  color: var(--text-color);
  margin-bottom: 5px;
}

.active-product-label {
  font-size: 1.4rem;
  color: var(--text-muted-color);
}

.no-active-calls {
  font-size: 1.8rem;
  color: var(--text-muted-color);
  text-align: center;
}

/* Ad banner layout: keeps the hero "current call" card and the "recent
   calls" list exactly as they are when the banner is off (same components,
   same distinct styling), just stacked into a narrower left column, freeing
   the right column for a large rotating ad image. The waiting-tickets panel
   is dropped in this mode — there isn't room for a third panel, and knowing
   the current + recent calls is what matters most to someone glancing at
   the screen while the ad plays. Explicit grid-column/row placement moves
   the existing elements without touching their DOM order. */
.display-grid.banner-mode {
  grid-template-columns: 0.85fr 1.35fr;
  grid-template-rows: 0.65fr 1.35fr;
}

.display-grid.banner-mode .active-call-area {
  grid-column: 1;
  grid-row: 1;
}

.display-grid.banner-mode .right-sidebar {
  grid-column: 1;
  grid-row: 2;
  grid-template-rows: 1fr;
}

.display-grid.banner-mode .waiting-tickets {
  display: none;
}

.display-grid.banner-mode .promo-banner-area {
  grid-column: 2;
  grid-row: 1 / 3;
}

/* Smaller hero call card so it fits half-height without overwhelming the
   narrower left column. */
.display-grid.banner-mode .active-ticket-num {
  font-size: 5rem;
}

.display-grid.banner-mode .active-window-label {
  font-size: 2.6rem;
}

.display-grid.banner-mode .active-product-label {
  font-size: 1rem;
}

.display-grid.banner-mode .active-call-area {
  padding: 24px;
}

.promo-banner-area {
  background-color: var(--card-color);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.promo-banner-area img {
  width: 100%;
  height: 100%;
  /* contain (not cover): always shrink the whole creative to fit the frame
     instead of cropping/zooming into it, so nothing important gets cut off. */
  object-fit: contain;
  display: block;
}

/* Правая секция: Список последних вызовов и ожидания */
.right-sidebar {
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(0, 1fr);
  grid-gap: 24px;
  min-height: 0;
}

.sidebar-panel {
  background-color: var(--card-color);
  border-radius: 24px;
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-list {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-ticket-row + .sidebar-ticket-row {
  margin-top: 12px;
}

/* Рендеринг билетов в боковой панели */
.sidebar-ticket-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: rgba(255, 255, 255, 0.02);
  padding: 16px 24px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.02);
  transition: transform 0.2s ease;
}

.sidebar-ticket-row:hover {
  transform: translateX(5px);
  background-color: rgba(255, 255, 255, 0.04);
}

.side-ticket-num {
  font-size: 2.2rem;
  font-weight: 800;
}

.recent-calls .side-ticket-num {
  color: var(--accent-color);
}

.waiting-tickets .side-ticket-num {
  color: var(--waiting-color);
}

.side-ticket-details {
  text-align: right;
}

.side-window {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-color);
}

.side-product {
  font-size: 0.95rem;
  color: var(--text-muted-color);
}

.empty-state {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.15rem;
  color: var(--text-muted-color);
}

/* Модальное окно настроек (Settings Modal) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.settings-modal {
  background-color: #1e293b;
  width: 650px;
  max-width: 90%;
  max-height: 85vh;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.open .settings-modal {
  transform: translateY(0);
}

.modal-header {
  padding: 24px 30px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted-color);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease;
}

.close-btn:hover {
  color: var(--text-color);
}

.modal-body {
  padding: 30px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.modal-body > * + * {
  margin-top: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group > * + * {
  margin-top: 8px;
}

.form-group label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted-color);
}

.form-group input, .form-group select {
  background-color: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-color);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-group input:focus, .form-group select:focus {
  border-color: var(--primary-color);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 16px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.checkbox-group input {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  accent-color: var(--primary-color);
  cursor: pointer;
}

.checkbox-group span {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-color);
}

.theme-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-gap: 10px;
  margin-top: 5px;
}

.theme-preset-btn {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background-color: rgba(15, 23, 42, 0.3);
  color: var(--text-color);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-preset-btn.active {
  border-color: var(--primary-color);
  background-color: var(--primary-color);
}

.modal-footer {
  padding: 24px 30px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: flex-end;
}

.modal-footer > * + * {
  margin-left: 16px;
}

.btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-size: 1rem;
}

.btn.primary {
  background-color: var(--primary-color);
  color: #ffffff;
}

.btn.primary:hover {
  filter: brightness(1.1);
}

.btn.secondary {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-color);
}

.btn.secondary:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Кнопка открытия настроек (floating settings button) */
#floating-settings-trigger {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  opacity: 0; /* скрыто по умолчанию, показывается при ховере в угол */
  transition: opacity 0.3s ease, background-color 0.2s ease;
  z-index: 500;
}

body:hover #floating-settings-trigger {
  opacity: 0.6;
}

#floating-settings-trigger:hover {
  opacity: 1 !important;
  background-color: var(--primary-color);
}

#floating-settings-trigger svg {
  width: 22px;
  height: 22px;
  fill: #ffffff;
}

/* Масштаб интерфейса в настройках (− 100% + Сброс) */
.scale-control {
  display: flex;
  align-items: center;
}

.scale-control > * + * {
  margin-left: 10px;
}

.scale-btn {
  min-width: 52px;
  font-size: 1.4rem;
  padding: 6px 16px;
}

.scale-value {
  min-width: 64px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.screen-diagnostics {
  font-size: 0.75rem;
  color: var(--text-muted-color);
  word-break: break-all;
}

/* Навигация пультом (D-pad): фокус должен быть хорошо виден */
.settings-modal button:focus,
.settings-modal input:focus,
.settings-modal select:focus {
  outline: 3px solid var(--accent-color);
  outline-offset: 2px;
}

#floating-settings-trigger:focus {
  opacity: 1;
  outline: 3px solid var(--accent-color);
}
