:root {
  color-scheme: light;
  --brand-ink: #1f2a33;
  --brand-primary: #2b638f;
  --brand-primary-soft: #e6eff5;
  --brand-secondary: #62b136;
  --brand-secondary-hover: #4f952a;
  --brand-secondary-soft: #eaf5e3;
  --brand-bg: #ffffff;
  --surface-muted: var(--brand-primary-soft);
  --surface-border: #d8e1e8;
  --text-muted: #6b7c81;
}

html,
body {
  height: 100%;
  background: var(--brand-bg);
  margin: 0;
  color: var(--brand-ink);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

body.chat-body--minimized {
  overflow: hidden;
}

.chat-app {
  max-width: 460px;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.chat-app--minimized {
  height: 100%;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
}

.chat-app--minimized .chat-card {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  max-height: 0;
  margin: 0;
  border-width: 0;
}

.chat-app--minimized .chat-header {
  margin-bottom: 0 !important;
}

.chat-header {
  padding: 12px 14px;
  background: var(--brand-primary);
  color: var(--brand-bg);
  border-radius: 16px;
  box-shadow: 0 10px 24px rgba(43, 99, 143, 0.16);
}

.chat-header .text-muted {
  color: rgba(255, 255, 255, 0.72) !important;
}

.chat-title {
  display: inline-flex;
  align-items: center;
}

.chat-title-text {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.chat-title-icon {
  display: none;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
}

.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.18);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.chat-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 0.75rem;
}

.chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-secondary);
  box-shadow: 0 0 0 3px rgba(98, 177, 54, 0.22);
}

.chat-card {
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid var(--surface-border);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  max-height: 800px;
  overflow: hidden;
  transition: opacity 0.28s ease, transform 0.28s ease, max-height 0.28s ease,
    margin 0.28s ease;
}

.chat-card {
  background: var(--brand-bg);
}

.chat-messages {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 10px;
  overflow-y: auto;
  padding: 14px 16px 8px;
}

.message {
  padding: 10px 14px;
  border-radius: 14px;
  max-width: 90%;
  word-break: break-word;
  font-size: 0.95rem;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
}

.message--user {
  align-self: flex-end;
  background: var(--brand-secondary-soft);
  color: var(--brand-ink);
  border: 1px solid rgba(98, 177, 54, 0.35);
}

.message--bot {
  align-self: flex-start;
  background: var(--surface-muted);
  color: var(--brand-ink);
  border: 1px solid var(--surface-border);
}

.chat-typing {
  min-height: 20px;
  color: var(--text-muted);
}

.chat-app .card-footer {
  padding: 12px 16px 16px;
}

.chat-app .form-control {
  border-radius: 12px 0 0 12px;
  border: 1px solid var(--surface-border);
  background: var(--brand-bg);
  color: var(--brand-ink);
  font-size: 0.95rem;
  box-shadow: none;
}

.chat-app .form-control:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.2rem rgba(43, 99, 143, 0.2);
}

.chat-app .btn-primary {
  border-radius: 0 12px 12px 0;
  background: var(--brand-secondary);
  border-color: var(--brand-secondary);
  color: #ffffff;
  font-weight: 600;
}

.chat-app .btn-primary:hover,
.chat-app .btn-primary:focus {
  background: var(--brand-secondary-hover);
  border-color: var(--brand-secondary-hover);
  color: #ffffff;
}

.chat-app .btn-outline-secondary {
  border-radius: 999px;
  border-color: rgba(255, 255, 255, 0.4);
  color: var(--brand-bg);
}

.chat-app .chat-toggle-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  position: relative;
}

.chat-app .chat-toggle-icon {
  transition: transform 0.2s ease;
}

.chat-app--minimized .chat-toggle-icon--chevron {
  transform: rotate(180deg);
}

.chat-app--minimized .chat-toggle-icon--message {
  transform: none;
}

.chat-toggle-icon--message {
  display: none;
}

body.chat-device--phone .chat-app--minimized .chat-toggle-btn::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-secondary);
  box-shadow: 0 0 0 0 rgba(98, 177, 54, 0.55);
  animation: chat-dot-pulse 1.8s ease-out infinite;
}

@keyframes chat-dot-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(98, 177, 54, 0.55);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(98, 177, 54, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(98, 177, 54, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  body.chat-device--phone .chat-app--minimized .chat-toggle-btn::after {
    animation: none;
  }
}

.chat-app .btn-outline-secondary:hover,
.chat-app .btn-outline-secondary:focus {
  background: rgba(255, 255, 255, 0.18);
  color: var(--brand-bg);
  border-color: rgba(255, 255, 255, 0.7);
}

.chat-app .text-muted {
  color: var(--text-muted) !important;
}

@media (max-width: 767px) {
  body.chat-device--phone .chat-app--minimized.container {
    padding: 0 !important;
  }

  body.chat-device--phone .chat-app--minimized .chat-title-text,
  body.chat-device--phone .chat-app--minimized .chat-status {
    display: none;
  }

  body.chat-device--phone .chat-app--minimized .chat-title-icon {
    display: inline-flex;
  }

  body.chat-device--phone .chat-app--minimized .chat-header {
    height: 100%;
    border-radius: 12px;
    box-shadow: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  body.chat-device--phone .chat-app--minimized .chat-header-main {
    display: none !important;
  }

  body.chat-device--phone .chat-app--minimized .chat-header-actions {
    width: 100%;
    justify-content: center;
  }

  body.chat-device--phone .chat-app--minimized .chat-toggle-icon--chevron {
    display: none;
  }

  body.chat-device--phone .chat-app--minimized .chat-toggle-icon--message {
    display: block;
  }

  body.chat-device--phone .chat-app--minimized .chat-toggle-btn {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.45);
    box-shadow: 0 0 0 2px rgba(43, 99, 143, 0.2);
  }

  body.chat-device--phone .chat-header {
    padding: 10px 12px;
    border-radius: 14px;
  }

  body.chat-device--phone .chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 0.75rem;
  }

  body.chat-device--phone .chat-status {
    font-size: 0.7rem;
    padding: 2px 6px;
  }

  body.chat-device--phone .chat-messages {
    padding: 12px 12px 6px;
    gap: 8px;
  }

  body.chat-device--phone .message {
    font-size: 0.9rem;
  }

  body.chat-device--phone .chat-app .card-footer {
    padding: 10px 12px 12px;
  }
}
