/* chat.css — chat-onboarding frontend, минимальная вёрстка. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #1a1a1a;
  background: #fafafa;
}

body {
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #ffffff;
  border-bottom: 1px solid #e5e5e5;
  flex: 0 0 auto;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  color: #1a1a1a;
}

.pilot-info {
  font-size: 14px;
  color: #666;
}
.pilot-info:empty { display: none; }

.chat {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  min-height: 0;
}

.cv-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #fff7e0;
  border: 2px solid #f0c060;
  border-radius: 0 0 8px 8px;
  font-size: 15px;
  font-weight: 500;
  color: #5a4a00;
  transition: padding 0.2s, font-size 0.2s;
  animation: cvPulse 2.4s ease-in-out infinite;
}
@keyframes cvPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(240,192,96,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(240,192,96,0); }
}
.cv-bar.uploaded {
  background: #e8f7ec;
  border: 1px solid #c4e6cc;
  border-radius: 0 0 8px 8px;
  color: #14532d;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: normal;
  animation: none;
  box-shadow: none;
}
.cv-bar.uploading {
  background: #fff8e1;
  border: 1px solid #f0e0a0;
  color: #5a4a00;
  animation: none;
  box-shadow: none;
}
.cv-bar.error {
  background: #fde7e9;
  border: 1px solid #f5c0c5;
  color: #7a1c25;
  animation: none;
  box-shadow: none;
}
.cv-bar.hidden { display: none; }
.cv-status { flex: 1 1 auto; }
.cv-button {
  flex: 0 0 auto;
  padding: 6px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  background: #ffffff;
  color: #2d6cdf;
  border: 1px solid #2d6cdf;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.cv-button:hover { background: #f0f6ff; }
.cv-bar.uploaded .cv-button,
.cv-bar.uploading .cv-button { display: none; }
/* Кнопка "заменить" — показывается ТОЛЬКО при наведении на компактный uploaded-баннер */
.cv-bar.uploaded .cv-replace {
  display: none;
  flex: 0 0 auto;
  font-size: 12px;
  color: #2d6cdf;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}
.cv-bar.uploaded:hover .cv-replace { display: inline; }

.messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg.user {
  align-self: flex-end;
  background: #2d6cdf;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.msg.assistant {
  align-self: flex-start;
  background: #ffffff;
  color: #1a1a1a;
  border: 1px solid #e5e5e5;
  border-bottom-left-radius: 4px;
}

.msg.system {
  align-self: center;
  background: #fff8e1;
  color: #5a4a00;
  border: 1px solid #f0e0a0;
  font-size: 14px;
  text-align: center;
  max-width: 95%;
}

.msg-typing {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e5e5e5;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 14px 18px;
  display: inline-flex;
  gap: 4px;
}
.msg-typing span {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.msg-typing span:nth-child(2) { animation-delay: 0.15s; }
.msg-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.composer {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid #e5e5e5;
}

.composer textarea {
  flex: 1 1 auto;
  resize: none;
  padding: 10px 14px;
  font: inherit;
  border: 1px solid #d0d0d0;
  border-radius: 12px;
  outline: none;
  max-height: 160px;
  overflow-y: auto;
}
.composer textarea:focus {
  border-color: #2d6cdf;
  box-shadow: 0 0 0 3px rgba(45,108,223,0.15);
}

.composer button {
  flex: 0 0 auto;
  padding: 0 18px;
  font: inherit;
  font-weight: 600;
  background: #2d6cdf;
  color: #ffffff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 110px;
  transition: background 0.15s;
}
.composer button:hover:not(:disabled) {
  background: #1f5bc4;
}
.composer button:disabled {
  background: #aaa;
  cursor: not-allowed;
}

.spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.composer button.loading .send-label { display: none; }
.composer button.loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.error-screen {
  position: fixed;
  inset: 0;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  z-index: 100;
}
.error-screen h2 {
  font-size: 22px;
  margin: 0 0 12px 0;
}
.error-screen p {
  margin: 0;
  color: #555;
  max-width: 480px;
}
.hidden { display: none !important; }

@media (max-width: 600px) {
  .topbar { padding: 10px 12px; }
  .topbar h1 { font-size: 16px; }
  .messages { padding: 16px 12px; }
  .composer { padding: 10px 12px; }
  .composer button { min-width: 80px; padding: 0 12px; }
}
