/* ============================================================
   desktop.css — режим Electron-обёртки
   Включается классом html.is-desktop (его ставит инлайновый скрипт
   в <head> при user-agent вида "Electron/").

   В обёртке нет «рабочего стола»: каждое окно приложения — настоящий
   BrowserWindow без системной рамки, поэтому окно Win98 растягивается
   на весь BrowserWindow, а его заголовок становится drag-зоной.
   ============================================================ */

html.is-desktop,
html.is-desktop body {
  height: 100%;
  overflow: hidden;
  background: var(--face);
}

/* «Рабочий стол», панель задач и «Пуск» живут только в браузере */
html.is-desktop .desk-icons,
html.is-desktop .desk-watermark,
html.is-desktop .taskbar,
html.is-desktop .startmenu {
  display: none !important;
}

html.is-desktop .desktop {
  background: var(--face);
  background-image: none;
  padding: 0;
}

/* Окно занимает всё пространство настоящего окна */
html.is-desktop .win {
  position: absolute;
  inset: 0;
  left: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: auto !important;
  height: auto !important;
  max-height: none;
  margin: 0;
  transform: none !important;
  box-shadow: none;
  border-radius: 0;
  z-index: 20;
}

html.is-desktop .win.hidden { display: none !important; }

/* Сплэш загрузки занимает всё окно: вместо «мгновенного» главного экрана
   пользователь видит тот самый экран запуска с прогресс-баром */
html.is-desktop .win.splash {
  border: 0;
  box-shadow: none;
  z-index: 40;
  /* в браузере сплэш по центру (left/top: 50% + translate), здесь — на всё окно */
  transform: none !important;
}

html.is-desktop .win.splash .titlebar { -webkit-app-region: drag; }

html.is-desktop .win.splash .splash-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  height: calc(100% - 22px);
  padding: 24px 32px 40px;
}

html.is-desktop .win.splash .splash-logo { margin-bottom: 20px; }
html.is-desktop .win.splash .splash-logo b { font-size: 19px; }
html.is-desktop .win.splash .splash-logo small { font-size: 12px; }
html.is-desktop .win.splash .progress { height: 20px; margin: 0 0 10px; }
html.is-desktop .win.splash .progress-text { font-size: 12px; }

html.is-desktop .win.splash .splash-foot {
  position: absolute;
  left: 32px;
  right: 32px;
  bottom: 20px;
  text-align: center;
}

html.is-desktop .win.splash.done {
  opacity: 0;
  transform: none !important;
  transition: opacity 0.28s ease;
  pointer-events: none;
}

/* Пока идёт загрузка, рабочие окна скрыты — виден только сплэш */
html.is-desktop body.is-booting .desktop > .win:not(.splash) {
  visibility: hidden !important;
}

/* Заголовок — панель окна: заметная полоса с названием и кнопками */
html.is-desktop .titlebar {
  flex: 0 0 auto;
  min-height: 22px;
  height: 22px;
  padding-left: 4px;
  font-size: 12px;
  cursor: default;
  /* на Linux перетаскивание делаем сами через IPC (см. js/desktop.js),
     потому что -webkit-app-region там часто не срабатывает */
  -webkit-app-region: no-drag;
  -webkit-user-select: none;
  user-select: none;
}

html.is-desktop:not(.desktop-linux) .titlebar { -webkit-app-region: drag; }

html.is-desktop .titlebar-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

html.is-desktop .titlebar-btns,
html.is-desktop .titlebar-btns *,
html.is-desktop .menubar,
html.is-desktop .menubar * {
  -webkit-app-region: no-drag;
}

/* Кнопки окна — крупнее, чтобы попадать мышью без прицеливания */
html.is-desktop .tb-btn {
  width: 20px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

html.is-desktop .titlebar-icon svg { width: 13px; height: 13px; }

/* Развёрнуто: кнопка показывает «восстановить» — два наложенных окна */
html.is-desktop .tb-max::before {
  width: 8px;
  height: 6px;
  top: 58%;
}

html.is-desktop.is-maximized .tb-max::before {
  width: 6px;
  height: 5px;
  box-shadow: 2px -2px 0 -1px var(--face), 2px -2px 0 0 #000;
}

/* Пункты, которые нужны только в браузере (переход в приложение по longcall://) */
html.is-desktop .only-web { display: none !important; }

/* Всплывающие уведомления не должны перекрывать кнопки окна */
html.is-desktop .toasts {
  bottom: 8px;
  right: 8px;
}

/* Диалоги: чуть плотнее, окно и так небольшое */
html.is-desktop .modal-layer { padding: 10px; }
html.is-desktop .modal { max-height: calc(100% - 24px); }

/* Поля ввода и списки в обёртке не должны «тянуть» окно за собой */
html.is-desktop .listbox,
html.is-desktop .call-log,
html.is-desktop .win-content {
  overscroll-behavior: contain;
}

/* На узких окнах обёртки прячем лишнее так же, как в мобильной вёрстке */
@media (max-width: 560px) {
  html.is-desktop .hero-hint { display: none; }
  html.is-desktop .hero-logo { width: 38px; height: 38px; }
}
