@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700&display=swap");

:root {
  --accent: #e3b341;
  --accent-dim: rgba(227, 179, 65, 0.25);
  --surface: rgba(30, 27, 46, 0.92);
  --surface-elevated: rgba(42, 39, 58, 0.95);
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  background: linear-gradient(165deg, #1a1730 0%, #12101f 45%, #0e0c18 100%);
  color: rgba(255, 255, 255, 0.92);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-main {
  padding-bottom: calc(4.5rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  .app-main {
    padding-bottom: 0;
  }
}

.mobile-nav {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.avatar {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  font-weight: 600;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.avatar-sm {
  width: 2rem;
  height: 2rem;
  font-size: 0.65rem;
}
.avatar-md {
  width: 2.5rem;
  height: 2.5rem;
  font-size: 0.8rem;
}
.avatar-lg {
  width: 3rem;
  height: 3rem;
  font-size: 0.9rem;
}

/* Оценка: панель шага «приезжает» справа */
.eval-panel-inner {
  will-change: opacity, transform;
}

.eval-panel-animating {
  animation: evalPanelSlideIn 0.38s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes evalPanelSlideIn {
  from {
    opacity: 0;
    transform: translateX(1.75rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.eval-intel-hints {
  margin-top: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(227, 179, 65, 0.35);
  background: rgba(227, 179, 65, 0.08);
}

.eval-intel-hints.hidden {
  display: none;
}

.eval-intel-hints__title {
  margin: 0 0 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(227, 179, 65, 0.95);
}

.eval-intel-hints__actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.eval-intel-hints__pick {
  width: 100%;
  border-radius: 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  padding: 0.5rem 0.65rem;
  text-align: left;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
}

.eval-intel-hints__pick:hover {
  border-color: rgba(227, 179, 65, 0.55);
  background: rgba(255, 255, 255, 0.1);
}

.eval-intel-hints__prev {
  margin-top: 0.65rem;
  font-size: 0.8rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.62);
}

.eval-intel-hints__lines p {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.75);
}

.eval-done-chip {
  border-left: 3px solid rgba(227, 179, 65, 0.85);
  background: rgba(255, 255, 255, 0.06);
}

.eval-done-chip--btn {
  display: block;
  width: 100%;
  border: none;
  border-left: 3px solid rgba(227, 179, 65, 0.85);
  cursor: pointer;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.eval-done-chip--btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.11);
  border-left-color: rgba(227, 179, 65, 1);
}

.eval-done-chip--btn:focus-visible {
  outline: 2px solid rgba(227, 179, 65, 0.65);
  outline-offset: 2px;
}

.eval-done-chip--btn:disabled {
  cursor: default;
}

.eval-scanner-video-shell video {
  display: block;
  min-height: min(56vw, 280px);
}

.eval-imei-scanner.hidden {
  display: none !important;
}

.eval-workspace {
  min-height: min(70dvh, 560px);
}

/* Чаты: отдельная «коробка» на высоту экрана, скролл только в ленте */
body:has(#chat-app) > .flex.min-h-dvh {
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.app-main:has(#chat-app) {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  padding-bottom: 0;
}

@media (max-width: 767px) {
  .app-main:has(#chat-app) {
    /* место под нижнюю навигацию */
    max-height: calc(100dvh - 4.25rem - env(safe-area-inset-bottom, 0px));
  }
}

#chat-app {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

#chat-app .chat-layout {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

#chat-list-panel,
#chat-thread-panel {
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Только один экран: либо плейсхолдер, либо переписка */
#chat-thread-panel:has(#thread-active:not(.hidden)) #thread-placeholder,
#chat-thread-panel:has(#thread-active:not(.hidden)) #thread-missing {
  display: none !important;
}

#chat-thread-panel:has(#thread-missing:not(.hidden)) #thread-placeholder,
#chat-thread-panel:has(#thread-missing:not(.hidden)) #thread-active {
  display: none !important;
}

#chat-list {
  flex: 1 1 0;
  min-height: 0;
}

#thread-active {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

#thread-active > header,
#thread-active > footer {
  flex-shrink: 0;
}

#thread-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#thread-messages img {
  max-height: min(36dvh, 280px);
  width: auto;
}

.chat-toast-root {
  position: fixed;
  right: max(0.75rem, env(safe-area-inset-right, 0px));
  bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  width: min(20rem, calc(100vw - 1.5rem));
  pointer-events: none;
  opacity: 0;
  transform: translateY(0.5rem);
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

@media (min-width: 768px) {
  .chat-toast-root {
    bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  }
}

.chat-toast-root--visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.chat-toast {
  position: relative;
  display: block;
  padding: 0.75rem 2rem 0.75rem 0.85rem;
  border-radius: 0.85rem;
  border: 1px solid rgba(227, 179, 65, 0.45);
  background: var(--surface-elevated);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
}

.chat-toast:hover {
  border-color: rgba(227, 179, 65, 0.75);
  background: rgba(50, 46, 70, 0.98);
}

.chat-toast__title {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.chat-toast__room {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.25;
}

.chat-toast__preview {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.62);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.chat-toast__close {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  width: 1.5rem;
  height: 1.5rem;
  border: none;
  border-radius: 0.4rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.45);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.chat-toast__close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
}

/* --- Светлая тема --- */
html[data-theme="light"] {
  color-scheme: light;
  --surface: rgba(248, 250, 252, 0.96);
  --surface-elevated: rgba(255, 255, 255, 0.98);
}

html[data-theme="light"] body.lombard-app {
  background: linear-gradient(165deg, #f8fafc 0%, #e2e8f0 48%, #f1f5f9 100%);
  color: #0f172a;
}

html[data-theme="light"] .text-white {
  color: #0f172a !important;
}

html[data-theme="light"] .text-white\/30 {
  color: rgb(148 163 184) !important;
}
html[data-theme="light"] .text-white\/35 {
  color: rgb(148 163 184) !important;
}
html[data-theme="light"] .text-white\/40 {
  color: rgb(100 116 139) !important;
}
html[data-theme="light"] .text-white\/45 {
  color: rgb(100 116 139) !important;
}
html[data-theme="light"] .text-white\/50 {
  color: rgb(100 116 139) !important;
}
html[data-theme="light"] .text-white\/55 {
  color: rgb(71 85 105) !important;
}
html[data-theme="light"] .text-white\/65 {
  color: rgb(71 85 105) !important;
}
html[data-theme="light"] .text-white\/70 {
  color: rgb(51 65 85) !important;
}
html[data-theme="light"] .text-white\/80 {
  color: rgb(30 41 59) !important;
}
html[data-theme="light"] .text-white\/90 {
  color: rgb(15 23 42) !important;
}

html[data-theme="light"] .border-white\/5 {
  border-color: rgb(226 232 240) !important;
}
html[data-theme="light"] .border-white\/10 {
  border-color: rgb(203 213 225) !important;
}
html[data-theme="light"] .border-white\/15 {
  border-color: rgb(203 213 225) !important;
}

html[data-theme="light"] .bg-surface,
html[data-theme="light"] .bg-surface\/30,
html[data-theme="light"] .bg-surface\/50,
html[data-theme="light"] .bg-surface\/80,
html[data-theme="light"] .bg-surface\/95 {
  background-color: var(--surface) !important;
}

html[data-theme="light"] .bg-elevated {
  background-color: var(--surface-elevated) !important;
}

html[data-theme="light"] .bg-white\/5 {
  background-color: rgb(241 245 249) !important;
}
html[data-theme="light"] .bg-white\/10 {
  background-color: rgb(241 245 249) !important;
}
html[data-theme="light"] .hover\:bg-white\/5:hover {
  background-color: rgb(226 232 240) !important;
}

html[data-theme="light"] .eval-done-chip {
  background: rgb(241 245 249);
  border-left-color: rgba(180, 130, 20, 0.85);
}

html[data-theme="light"] .eval-intel-hints {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(180, 130, 20, 0.35);
}

html[data-theme="light"] .eval-intel-hints__pick {
  background: #fff;
  border-color: rgb(203 213 225);
  color: #0f172a;
}

html[data-theme="light"] .placeholder\:text-white\/35::placeholder {
  color: rgb(148 163 184) !important;
}

html[data-theme="light"] .text-red-200 {
  color: rgb(185 28 28) !important;
}
html[data-theme="light"] .text-emerald-200 {
  color: rgb(4 120 87) !important;
}
html[data-theme="light"] .bg-red-500\/15 {
  background-color: rgb(254 226 226) !important;
}
html[data-theme="light"] .bg-emerald-500\/15 {
  background-color: rgb(209 250 229) !important;
}
