﻿/* MODULE_OVERVIEW
 * Глобальные стили web-интерфейса и визуальная тема проекта.
 * Содержит актуальные доработки UX: выделенный idDrawerHandle, локальный GIF-слой и фон scroll с локальным газовым SVG-паттерном.
 * Поддерживает адаптивный layout с левой SEO-панелью и мобильной совместимостью.
 */

/* ===== Base ===== */
:root {
  --bg: #e6f0fa;
  --phone-bg: #0a4ea1;
  --screen-bg1: #ffffff;
  --screen-bg2: #ffffff;

  --primary: #0a4ea1;
  --primary-hover: #083d80;
  --light-secondary: #e6f0fa;
  --main-bg: #ffffff;
  --text: #1a1a1a;
  --muted: #333333;
  --border: #dce3eb;
  --chat-active: #dceaf7;
  --input-bg: #f5f7fa;
  --shadow: 0 18px 55px rgba(10, 78, 161, 0.22);

  --card: #ffffff;

  --radius: 26px;
  --radius-inner: 18px;

  --handle-h: 28px;
  --drawer-open-h: 140px;

  --gap: 5px;
  --pad: 6px;

  --notch-top: 8px;
  --notch-h: 24px;

  --mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --ui:
    system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Arial,
    sans-serif;

  --btn-h: 30px;
  --btn-r: 10px;
  --btn-bg: var(--primary);
  --btn-bg-hover: var(--primary-hover);
  --btn-border: var(--primary);
  --btn-border-strong: var(--primary-hover);

  --accent: var(--primary);
  --success: #1f9d55;
  --warn: #b37d21;
  --danger: #ba3c3c;

  --active-bg: var(--chat-active);
  --active-border: var(--primary);
  --menu-bg: var(--light-secondary);
  --menu-border: var(--primary);

  --sleep-opacity: 0.55;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: var(--ui);
  background: radial-gradient(circle at 18% 5%, #ffffff 0%, var(--bg) 70%);
  color: var(--text);
}

body {
  min-height: 100%;
  background: radial-gradient(circle at 18% 5%, #ffffff 0%, var(--bg) 70%);
  color: var(--text);
}

.page-shell {
  width: min(1220px, 98vw);
  margin: 2.5vh auto;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(340px, 420px);
  gap: 20px;
  align-items: start;
}

.seo-hints {
  min-height: min(860px, 96vh);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #ffffffcc;
  backdrop-filter: blur(2px);
  box-shadow: 0 10px 30px rgba(10, 78, 161, 0.08);
  overflow: hidden;
}

.seo-hints-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  color: var(--primary);
  background: #f2f7fd;
}

.seo-hints-body {
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.5;
}

.seo-hints-body h1,
.seo-hints-body h2,
.seo-hints-body h3,
.seo-hints-body p {
  margin-top: 0;
}

.mono {
  font-family: var(--mono);
}

.readonly {
  opacity: 0.92;
}

.token-hidden {
  position: absolute;
  left: -10000px;
  top: -10000px;
}

/* ===== Phone shell ===== */
.phone {
  width: min(420px, 96vw);
  height: min(860px, 96vh);
  margin: 0;
  padding: 14px;
  border-radius: calc(var(--radius) + 10px);
  background: linear-gradient(180deg, #0b4a97 0%, var(--phone-bg) 100%);
  box-shadow: var(--shadow);
  position: relative;
  border: 1px solid #083d80;
}

/* ===== Notch ===== */
.notch {
  position: absolute;
  top: var(--notch-top);
  left: 50%;
  transform: translateX(-50%);
  height: var(--notch-h);
  border-radius: 0 0 18px 18px;
  background: var(--primary);
  opacity: 0.95;
  z-index: 6;

  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.2px;
  opacity: 0.95;
  font-size: 14px;
  white-space: nowrap;
  color: #ffffff;
}

.camera {
  display: none;
}

/* ===== Screen ===== */
.screen {
  height: 100%;
  width: 100%;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(
    180deg,
    var(--screen-bg1) 0%,
    var(--screen-bg2) 100%
  );
  display: flex;
  flex-direction: column;
  position: relative;
  padding-top: 0;
}

/* ===== Layout rows & inputs ===== */
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.lbl {
  font-size: 14px;
  color: var(--muted);
}

input[type="text"] {
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  padding: 0 12px;
  outline: none;
  min-width: 0;
}

input[type="text"]::placeholder {
  color: #6b7280;
}

input[type="text"]:focus {
  border-color: var(--primary);
  background: #ffffff;
}

/* ===== Generic buttons ===== */
.btn {
  height: var(--btn-h);
  border-radius: var(--btn-r);
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: #ffffff;
  cursor: pointer;
  line-height: 1;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    opacity 120ms ease,
    transform 80ms ease,
    box-shadow 120ms ease;
}

.btn:hover {
  background: var(--btn-bg-hover);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: none;
  border-color: var(--btn-border-strong);
  box-shadow: 0 0 0 2px rgba(10, 78, 161, 0.16);
}

.btn {
  padding: 0 14px;
}

.wb-btn,
.rk-btn {
  height: var(--btn-h);
  border-radius: var(--btn-r);
  border: 1px solid var(--border);
  background: var(--light-secondary);
  color: var(--primary);
  cursor: pointer;
  line-height: 1;
  transition:
    background 120ms ease,
    border-color 120ms ease,
    opacity 120ms ease,
    transform 80ms ease,
    box-shadow 120ms ease;
  padding: 0 10px;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wb-btn:hover,
.rk-btn:hover {
  background: #dceaf7;
}

.wb-btn:active,
.rk-btn:active {
  transform: translateY(1px);
}

.wb-btn:focus-visible,
.rk-btn:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(10, 78, 161, 0.14);
}

.wb-btn.is-menu,
.rk-btn.is-menu {
  background: var(--menu-bg);
  border-color: var(--menu-border);
}

.wb-btn.is-active,
.rk-btn.is-active {
  background: var(--active-bg);
  border-color: var(--active-border);
  box-shadow: inset 0 0 0 1px rgba(10, 78, 161, 0.15);
}

/* Clickable field in main text (active and inactive). */
.wb-field {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 0 4px;
  border-radius: 10px;
}

.wb-field--active {
  background: var(--active-bg);
  border: 1px solid var(--active-border);
}

/* Clickable list item (object / tgu list) */
.wb-list-item {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  padding: 4px 4px;
  border-radius: 10px;
  box-sizing: border-box;
}
.wb-list-item:hover {
  background: var(--light-secondary);
}

.wb-btn.is-success,
.rk-btn.is-success {
  border-color: rgba(126, 231, 135, 0.42);
}

.wb-btn.is-warn,
.rk-btn.is-warn {
  border-color: rgba(255, 197, 92, 0.42);
}

.wb-btn.is-danger,
.rk-btn.is-danger {
  border-color: rgba(255, 107, 107, 0.42);
}

.wb-btn.is-ghost,
.rk-btn.is-ghost {
  background: #f2f6fb;
}

.wb-btn.is-compact,
.rk-btn.is-compact {
  height: 34px;
  border-radius: 12px;
  font-size: 12px;
}

.wb-btn.is-pill,
.rk-btn.is-pill {
  border-radius: 999px;
}

/* ===== ID Drawer ===== */
.id-drawer {
  position: relative;
  flex: 0 0 auto;
  background: var(--main-bg);
  border-bottom: 1px solid var(--border);
}

.id-drawer-handle {
  height: var(--handle-h);
  display: flex;
  align-items: center;
  padding: 0 var(--pad);
  cursor: default;
  user-select: none;
  position: relative;
  overflow: hidden;
  background: #0a4ea1;
  border-top: 1px solid #083d80;
  border-bottom: 1px solid #083d80;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);
  transition: background 120ms ease;
}

.id-drawer-handle:hover {
  background: #0b58b8;
}

.id-drawer-handle::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("/assets/id-handle-stripes.gif");
  background-size: cover;
  background-position: center;
  opacity: 0.18;
  pointer-events: none;
}

.id-drawer-handle-text {
  position: relative;
  z-index: 1;
  font-size: 13.5px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
}

.id-drawer-body {
  padding: 10px var(--pad) 12px var(--pad);
  overflow: auto;
  transition:
    max-height 180ms ease,
    opacity 140ms ease,
    padding 180ms ease;
  will-change: max-height, opacity, padding;
}

.id-drawer.collapsed .id-drawer-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

.id-drawer.expanded .id-drawer-body {
  max-height: var(--drawer-open-h);
  opacity: 1;
}

.id-drawer:hover .id-drawer-body,
.id-drawer:focus-within .id-drawer-body {
  max-height: var(--drawer-open-h);
  opacity: 1;
  padding: 10px var(--pad) 12px var(--pad);
}

.id-drawer.collapsed::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: var(--handle-h);
  height: 18px;
  background: transparent;
}

.hint {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.sys-out {
  margin-top: 8px;
  font-size: 14px;
  color: var(--muted);
  white-space: pre-wrap;
}

/* ===== Scroll area ===== */
.scroll {
  background-color: #d8e9fb;
  background-image:
    linear-gradient(
      180deg,
      rgba(236, 245, 255, 0.88) 0%,
      rgba(214, 232, 250, 0.9) 100%
    ),
    url("/assets/scroll-gas-pattern.svg");
  background-repeat: no-repeat, repeat;
  background-size:
    auto,
    240px 240px;
  background-position:
    center,
    0 0;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  align-items: stretch;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.scroll::-webkit-scrollbar {
  width: 10px;
}

.scroll::-webkit-scrollbar-thumb {
  background: #8db5da;
  border-radius: 10px;
  border: 2px solid #d4e6f8;
}

.scroll::-webkit-scrollbar-track {
  background: #eaf3fc;
}

/* ===== Pane blocks ===== */
.pane {
  display: block;
  flex: 0 0 auto;
  min-height: fit-content;
  min-width: 0;
  border-radius: var(--radius-inner);
  border: 1px solid var(--border);
  background: var(--card);
  overflow: visible;
}

.pane-title {
  display: none;
}

.pane-body {
  padding: 6px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.38;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#mainBody,
#pendingBody,
#alertBody,
#replyBody {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.pane.main {
  background: var(--main-bg);
}

.pane.pending {
  background: var(--light-secondary);
  border-color: var(--border);
}

.placeholder {
  opacity: 0.82;
  font-style: italic;
}

/* ===== Main / Pending content helpers ===== */
.wb-main,
.wb-pending {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.wb-main-text,
.wb-pending-text {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.wb-main-nav,
.wb-main-submenu,
.wb-pending-nav,
.wb-pending-submenu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  width: 100%;
}

[class$="-grid"],
.wb-grid {
  width: 100%;
}

[class$="-grid-row"],
.wb-grid-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  width: 100%;
  min-width: 0;
  justify-content: space-between;
}

.wb-btn {
  min-width: 72px;
}

/* ===== System note ===== */
.sys-note {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--light-secondary);
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===== Toast / Alert Pane ===== */
.toast {
  border-radius: 14px;
  padding: 10px 12px;
  background: var(--main-bg);
  border: 1px solid var(--border);
  color: var(--text);
  line-height: 1.3;
  font-size: 14px;
}

.pane.alert {
  display: none;
}

.pane.alert.visible {
  display: block;
}

.alert-body {
  padding: 12px;
  font-size: 15px;
  line-height: 1.38;
  color: var(--text);
  border-left: 4px solid var(--primary);
  background: var(--light-secondary);
}

.alert-body.info {
  border-left-color: var(--accent);
}

.alert-body.warn {
  border-left-color: var(--warn);
}

.alert-body.error {
  border-left-color: var(--danger);
}

.alert-body.success {
  border-left-color: var(--success);
}

/* ===== Composer ===== */
.composer {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
  padding: 5px var(--pad);
  border-top: 1px solid var(--border);
  background: var(--main-bg);
  position: relative;
}

.cmd-wrap {
  position: relative;
  flex: 0 0 auto;
}

.btn.cmd-toggle {
  width: 40px;
  padding: 0;
  font-weight: 800;
  height: 32px;
  border-radius: 10px;
  background: var(--light-secondary);
  border-color: var(--border);
  color: var(--primary);
  font-size: 18px;
}

.btn.cmd-toggle:hover {
  background: #dceaf7;
  border-color: var(--primary);
}

.cmd-pop {
  position: absolute;
  left: 0;
  bottom: 38px;
  z-index: 20;
  min-width: 140px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(10, 78, 161, 0.16);
}

.cmd-pop.hidden {
  display: none;
}

.cmd-item {
  display: block;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--primary);
  background: var(--light-secondary);
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.cmd-item:hover {
  background: #dceaf7;
  border-color: var(--primary);
}

.text-in {
  flex: 1 1 auto;
  height: 32px;
  border-radius: 10px;
  min-width: 0;
}

.btn.send,
.btn.toggle {
  width: 40px;
  padding: 0;
  font-weight: 800;
  height: 32px;
  border-radius: 10px;
}

.btn.send {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.btn.send:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn.toggle {
  font-size: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  background: var(--light-secondary);
  border-color: var(--border);
  color: var(--primary);
}

.btn.toggle.is-hidden {
  border-color: var(--border);
  background: var(--light-secondary);
}

.btn.toggle.is-shown {
  border-color: var(--primary);
  background: #dceaf7;
}

/* ===== Reply panel ===== */
.reply {
  flex: 0 0 auto;
  min-height: 0;
  background: var(--main-bg);
  border-top: 1px solid var(--border);
  overflow: hidden;
  transition:
    opacity 140ms ease,
    max-height 180ms ease;
}

.reply.shown {
  max-height: 40vh;
  opacity: 1;
}

.reply.hidden {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

.reply-title {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--secondary-text, #333333);
  border-bottom: 1px solid var(--border);
  background: var(--light-secondary);
}

.reply-body {
  padding: 10px 12px 12px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 40vh;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* ===== Button layouts ===== */
.rk,
.wb-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.rk-row,
.wb-row,
.wb-grid-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
  min-width: 0;
}

.rk-btn,
.wb-btn {
  flex: 1 1 0;
  min-width: 0;
}

.rk-row .rk-btn:only-child,
.wb-row .wb-btn:only-child,
.wb-grid-row .wb-btn:only-child {
  flex: 0 0 100%;
}

/* ===== Busy / sleeping / disabled ===== */
body.ui-busy button.wb-btn,
body.ui-busy button.rk-btn {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

button.wb-btn:disabled,
button.rk-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.rk-btn:disabled,
.wb-btn:disabled,
.btn:disabled {
  cursor: default;
  opacity: var(--sleep-opacity);
  transform: none !important;
  filter: grayscale(0.12) saturate(0.9);
  background: #e9eef4;
  border-color: var(--border);
}

.rk-btn:disabled:hover,
.wb-btn:disabled:hover,
.btn:disabled:hover {
  background: #e9eef4;
}

.wb-btn.is-sleeping,
.wb-btn[disabled] {
  opacity: var(--sleep-opacity);
  filter: grayscale(25%);
  cursor: default;
  pointer-events: none;
}

.wb-btn.is-busy,
.rk-btn.is-busy {
  pointer-events: none;
  cursor: progress;
  opacity: 0.8;
}

.wb-btn.is-selected,
.rk-btn.is-selected {
  background: var(--active-bg);
  border-color: var(--active-border);
}

.wb-btn.is-current-menu,
.rk-btn.is-current-menu {
  background: var(--menu-bg);
  border-color: var(--menu-border);
}

.wb-btn.is-soft-success,
.rk-btn.is-soft-success {
  background: rgba(126, 231, 135, 0.1);
  border-color: rgba(126, 231, 135, 0.3);
}

.wb-btn.is-soft-warn,
.rk-btn.is-soft-warn {
  background: rgba(255, 197, 92, 0.1);
  border-color: rgba(255, 197, 92, 0.3);
}

.wb-btn.is-soft-danger,
.rk-btn.is-soft-danger {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.3);
}

/* ===== File links ===== */
.file-link {
  display: inline-block;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--light-secondary);
  color: var(--primary);
  text-decoration: none;
  transition:
    background 120ms ease,
    opacity 120ms ease,
    transform 80ms ease;
  overflow-wrap: anywhere;
}

.file-link:hover {
  background: #dceaf7;
  opacity: 0.96;
}

/* ===== Messenger semantic blocks ===== */
.app-header {
  background: var(--primary);
  color: #ffffff;
}

.app-header .icon,
.app-header button,
.app-header a {
  color: #ffffff;
}

.app-header .is-active {
  color: var(--light-secondary);
}

.chat-list {
  background: var(--main-bg);
  border-right: 1px solid var(--border);
}

.chat-list .chat-item {
  border-bottom: 1px solid var(--border);
}

.chat-list .chat-item:hover {
  background: var(--light-secondary);
}

.chat-list .chat-item.is-active {
  background: var(--chat-active);
}

.chat-window {
  background: var(--main-bg);
}

.message.incoming,
.bubble.incoming {
  background: var(--light-secondary);
  color: var(--text);
  border-radius: 14px;
}

.message.outgoing,
.bubble.outgoing {
  background: var(--primary);
  color: #ffffff;
  border-radius: 14px;
}

.message-input,
.composer .text-in {
  background: var(--input-bg);
  border: 1px solid var(--border);
}

.main-nav,
.bottom-nav,
.wb-main-nav,
.wb-pending-nav {
  background: var(--main-bg);
  border-top: 1px solid var(--border);
}

.file-link:active {
  transform: translateY(1px);
}

.file-link-done {
  opacity: 0.6;
  cursor: default;
  pointer-events: none;
}

/* ===== Spinner ===== */
.spin {
  display: inline-block;
  animation: spin 1.1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ===== Mobile adaptation ===== */
@media (max-width: 600px) {
  html,
  body {
    height: 100%;
    min-height: 100%;
    background: var(--bg);
  }

  .page-shell {
    width: 100vw;
    margin: 0;
    display: block;
  }

  .seo-hints {
    display: none;
  }

  .phone {
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    border-radius: 0;
    background: var(--phone-bg);
    box-shadow: none;
    border: none;
  }

  .notch {
    top: 0;
    height: 34px;
    border-radius: 0 0 18px 18px;
  }

  .screen {
    border-radius: 0;
    padding-top: 0;
  }

  .scroll {
    padding: 10px;
    gap: 10px;
  }

  .pane-body,
  .reply-body {
    padding-left: 10px;
    padding-right: 10px;
  }
}

