:root {
  --brand-primary: #1565c0;
  --brand-dark: #0d47a1;
  --brand-gradient: linear-gradient(135deg, var(--brand-primary), var(--brand-dark));
  --bot-bg: #e8e8e8;
  --bot-text: #333;
  --error-bg: #ffebee;
  --error-text: #c62828;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f5;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* App layout: chat + help panel side by side */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100%;
}

.chat-container {
  flex: 1;
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.chat-header {
  background: var(--brand-gradient);
  color: white;
  padding: 16px 20px;
  text-align: center;
}

.chat-header h1 {
  font-size: 1.2rem;
  font-weight: 600;
}

.chat-header .subtitle {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-top: 4px;
}

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

.message {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 12px;
  line-height: 1.5;
  font-size: 0.95rem;
  word-wrap: break-word;
}

.message.bot {
  align-self: flex-start;
  background: var(--bot-bg);
  color: #333;
  border-bottom-left-radius: 4px;
}

.message.user {
  align-self: flex-end;
  background: var(--brand-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.message.error {
  align-self: flex-start;
  background: var(--error-bg);
  color: var(--error-text);
  border-bottom-left-radius: 4px;
}

.message.bot p { margin: 0 0 8px 0; }
.message.bot p:last-child { margin-bottom: 0; }
.message.bot ul, .message.bot ol { margin: 4px 0 8px 20px; padding: 0; }
.message.bot li { margin-bottom: 4px; }
.message.bot strong { font-weight: 600; }
.message.bot h1, .message.bot h2, .message.bot h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 8px 0 4px 0;
}
.message.bot code {
  background: rgba(0,0,0,0.06);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
}

.agent-tag {
  font-size: 0.7rem;
  color: #888;
  margin-top: 6px;
  font-style: italic;
}

.chips {
  padding: 8px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 12px;
  border-radius: 16px;
  border: 1px solid var(--brand-primary);
  background: white;
  color: var(--brand-primary);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.chip:hover {
  background: var(--brand-primary);
  color: white;
}

.input-area {
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #ddd;
  display: flex;
  gap: 8px;
}

.input-area input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 24px;
  font-size: 0.95rem;
  outline: none;
}

.input-area input:focus {
  border-color: var(--brand-primary);
}

.input-area button {
  padding: 10px 20px;
  background: var(--brand-gradient);
  color: white;
  border: none;
  border-radius: 24px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.input-area button:hover {
  opacity: 0.9;
}

.input-area button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.thinking {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.thinking span {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  animation: bounce 1.4s infinite ease-in-out;
}

.thinking span:nth-child(1) { animation-delay: -0.32s; }
.thinking span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Help panel */
.help-panel {
  width: 300px;
  background: white;
  border-left: 1px solid #ddd;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.help-panel.hidden {
  transform: translateX(100%);
  position: absolute;
  right: 0;
  pointer-events: none;
}

.help-header {
  background: var(--brand-gradient);
  color: white;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
}

.help-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.8;
}

.help-toggle:hover {
  opacity: 1;
}

.help-section {
  padding: 8px 12px;
  border-bottom: 1px solid #eee;
}

.help-category {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  padding-top: 4px;
}

.help-query {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  margin-bottom: 4px;
  background: #f8f9fa;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #333;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.3;
}

.help-query:hover {
  background: color-mix(in srgb, var(--brand-primary) 10%, white);
  border-color: var(--brand-primary);
  color: var(--brand-dark);
}

.help-query:active {
  background: var(--brand-primary);
  color: white;
}

/* Floating button to show panel when hidden */
.help-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: white;
  border: none;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  display: none;
  z-index: 10;
}

.help-fab:hover {
  opacity: 0.9;
}

.help-fab.visible {
  display: block;
}

/* Mobile: hide panel by default, show fab */
@media (max-width: 900px) {
  .help-panel {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    z-index: 20;
    box-shadow: -2px 0 12px rgba(0,0,0,0.15);
  }

  .help-panel.hidden {
    transform: translateX(100%);
  }

  .message { max-width: 90%; }
}
