/**
 * ACS Chat Room Styles
 * Styles for the Limited MCP ACS Chat Room interface
 * Extracted from limited-mcp-chat-room.html for better maintainability
 * Updated to use Fluent 2 Design System variables from styles.css
 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(
    --font-family,
    'Segoe UI',
    -apple-system,
    BlinkMacSystemFont,
    'Roboto',
    'Helvetica Neue',
    sans-serif
  );
  background: var(--colorNeutralBackground2, #f3f2f1);
  height: 100vh;
  margin: 0 !important; /* Override 4em margin from main styles */
  display: flex;
  flex-direction: column;
  color: var(--colorNeutralForeground1, #323130);
  overflow: hidden; /* Prevent body scroll */
}

/* Welcome Screen */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 40px;
  text-align: center;
  overflow-y: auto;
}

.welcome-screen h2 {
  color: var(--color-brand-primary, #6264a7);
  margin-bottom: 20px;
}

.welcome-screen .form-group {
  margin: 15px 0;
  width: 100%;
  max-width: 400px;
}

.welcome-screen input,
.welcome-screen textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--colorNeutralStroke1, #d1d1d1);
  border-radius: var(--border-radius-small, 4px);
  font-size: 14px;
  background-color: var(--colorNeutralBackground1, #ffffff);
  color: var(--colorNeutralForeground1, #242424);
}

.welcome-screen textarea {
  resize: vertical;
  min-height: 80px;
}

.welcome-screen button {
  background: var(--color-brand-primary, #6264a7);
  color: var(--color-white, white);
  border: none;
  padding: 12px 32px;
  border-radius: var(--border-radius-small, 4px);
  cursor: pointer;
  font-size: 16px;
  margin: 10px 5px;
  transition: background-color 0.2s;
}

.welcome-screen button:hover {
  background: var(--color-brand-primary-hover, #4b4d8c);
}

.welcome-screen button.secondary {
  background: var(--colorNeutralStroke2, #e0e0e0);
  color: var(--colorNeutralForeground1, #333);
}

.welcome-screen button.secondary:hover {
  background: var(--colorNeutralStroke1, #d0d0d0);
}

.rooms-list {
  max-width: 600px;
  width: 100%;
  margin-top: 20px;
}

.room-card {
  background: var(--colorNeutralBackground1, white);
  padding: 15px;
  margin: 10px 0;
  border-radius: var(--border-radius-medium, 8px);
  border: 1px solid var(--colorNeutralStroke2, #e0e0e0);
  cursor: pointer;
  transition: all 0.2s;
}

.room-card:hover {
  border-color: var(--color-brand-primary, #6264a7);
  box-shadow: var(--shadow-hover, 0 2px 8px rgba(98, 100, 167, 0.2));
}

.room-card h3 {
  color: var(--color-brand-primary, #6264a7);
  margin-bottom: 8px;
}

.room-card .room-meta {
  font-size: 13px;
  color: var(--colorNeutralForeground3, #666);
  margin-top: 8px;
}

/* Chat Container - Teams Style */
.chat-container {
  display: none;
  flex: 1;
  flex-direction: column;
  background: var(--colorNeutralBackground2, #f3f2f1);
  height: 100vh;
  overflow: hidden;
}

.chat-container.active {
  display: flex;
}

/* Messages Area - Teams Channel Style */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--colorNeutralBackground2, #f3f2f1);
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

/* Message Container - Teams Channel Style */
.message {
  display: flex;
  align-items: flex-start;
  margin-bottom: 8px;
  padding: 4px 0;
  animation: slideIn 0.2s ease-out;
}

.message.no-animate {
  animation: none;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Message Avatar - Teams Style */
.message-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--colorNeutralBackground2, #f3f2f1);
  color: var(--colorNeutralForeground1, #323130);
  border: 1px solid var(--colorNeutralStroke1, #dcdcdc);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
  margin-right: 8px;
}

.message-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.message-avatar-initials,
.message-avatar-emoji {
  font-size: 16px;
}

/* Message Content Container */
.message-content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 70%;
}

/* Sender Name - Teams Style */
.message .sender {
  font-weight: 600;
  font-size: 13px;
  color: var(--colorNeutralForeground1, #323130);
  margin-bottom: 2px;
  line-height: 1.2;
}

.message.bot .sender {
  color: var(--color-brand-primary, #6264a7);
}

/* Message Bubble - Teams Channel Style Refined */
.message .content {
  background: var(--colorNeutralBackground1, white);
  padding: 8px 12px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-wrap: break-word;
  line-height: 1.4;
  font-size: 14px;
  color: var(--colorNeutralForeground1, #242424);
  box-shadow: var(--shadow-2, 0 1px 2px rgba(0, 0, 0, 0.08));
  position: relative;
}

/* Bot messages - Left aligned */
.message.bot .content {
  background: var(--colorNeutralBackground1, white);
  border: 1px solid var(--colorNeutralStroke2, #e0e0e0);
  box-shadow: none;
}

/* User messages - Right aligned */
.message:not(.bot) {
  flex-direction: row-reverse;
}

.message:not(.bot) .message-content-wrapper {
  align-items: flex-end;
}

.message:not(.bot) .content {
  background: var(--color-brand-lighter, #e8ebfa);
  color: var(--colorNeutralForeground1, #242424);
  border: 1px solid var(--colorNeutralStroke1, #d1d1e0);
  box-shadow: none;
}

.message:not(.bot) .message-avatar {
  margin-right: 0;
  margin-left: 8px;
}

/* Markdown styling - Tighter spacing */
.message .content h1,
.message .content h2,
.message .content h3 {
  margin-top: 8px;
  margin-bottom: 4px;
  font-weight: 600;
  line-height: 1.2;
}

.message .content p {
  margin: 4px 0;
  line-height: 1.4;
}

.message .content ul,
.message .content ol {
  margin: 4px 0;
  padding-left: 20px;
}

.message .content li {
  margin: 2px 0;
}

/* Input Area - Modern/Teams Style */
.input-area {
  padding: 16px;
  background: var(--colorNeutralBackground1, white);
  border-top: 1px solid var(--colorNeutralStroke2, #edebe9);
  display: flex;
  gap: 10px;
  align-items: center;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
  flex-shrink: 0;
  z-index: 100;
}

.input-area input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--colorNeutralStroke1, #d1d1d1);
  border-radius: 20px; /* Pill shape */
  font-size: 14px;
  line-height: 1.4;
  background: var(--colorNeutralBackground3, #f5f5f5);
  color: var(--colorNeutralForeground1, #242424);
  transition: all 0.2s;
}

.input-area input:focus {
  outline: none;
  border-color: var(--color-brand-primary, #6264a7);
  background: var(--colorNeutralBackground1, white);
  box-shadow: 0 0 0 2px rgba(98, 100, 167, 0.1);
}

.input-area button {
  background: var(--color-brand-primary, #6264a7);
  color: var(--color-white, white);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  padding: 0;
}

.input-area button:hover {
  background: var(--color-brand-primary-hover, #4b4d8c);
}

.input-area button svg {
  width: 16px;
  height: 16px;
  fill: white;
}

/* Send Icon (using text fallback or svg if available) */
.input-area button::after {
  content: '➤';
  font-size: 14px;
  margin-left: 2px;
}

/* Hide text on button to use icon */
.input-area button {
  font-size: 0;
}

.input-area button:disabled {
  background: var(--colorNeutralStroke1, #ccc);
  cursor: not-allowed;
}

/* Loading Spinner */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Status Messages - Teams Style */
.status-message {
  text-align: center;
  padding: 10px 16px;
  margin: 12px 16px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.4;
  border: 1px solid;
}

.status-message.info {
  background: var(--color-info-light, #deecf9);
  color: var(--color-info, #004578);
  border-color: #c7e0f4;
}

.status-message.error {
  background: var(--color-danger-light, #fde7e9);
  color: var(--color-danger, #a80000);
  border-color: #f1bbbb;
}

.status-message.success {
  background: var(--color-success-light, #dff6dd);
  color: var(--color-success, #107c10);
  border-color: #92c5f7;
}

/* Typing Indicator - Teams Style */
.typing-indicator {
  padding: 8px 16px;
  font-size: 13px;
  color: var(--colorNeutralForeground3, #605e5c);
  font-style: italic;
  line-height: 1.4;
  display: flex;
  align-items: center;
  gap: 8px;
}

.typing-indicator::before {
  content: '●';
  animation: typingDots 1.4s infinite;
  font-size: 8px;
}

@keyframes typingDots {
  0%,
  60%,
  100% {
    opacity: 0.3;
  }
  30% {
    opacity: 1;
  }
}

/* Hidden */
.hidden {
  display: none !important;
}

/* Loading State Styles - Consolidated from limited-mcp-chat-room.html */
.loading-container {
  font-size: 48px;
  margin-bottom: 20px;
}

.loading-large {
  width: 60px;
  height: 60px;
  border-width: 5px;
  border-color: rgba(98, 100, 167, 0.3);
  border-top-color: var(--color-brand-primary, #6264a7);
}

.loading-subtitle {
  color: var(--colorNeutralForeground3, #666);
  margin-top: 10px;
}

/* Collapsible citation styles for raw JSON responses */
.message .content details {
  margin: 12px 0;
  border-left: 3px solid var(--color-info, #0078d4);
  background: var(--colorNeutralBackground2, #f8f9fa);
  border-radius: 4px;
  overflow: hidden;
}

.message .content details summary {
  cursor: pointer;
  padding: 10px 14px;
  color: var(--color-info, #0078d4);
  font-size: 0.9em;
  font-weight: 500;
  user-select: none;
  background: var(--color-info-light, #f0f6ff);
  transition: background 0.2s;
  list-style: none;
  line-height: 1.5;
}

.message .content details summary::-webkit-details-marker {
  display: none;
}

.message .content details summary::before {
  content: '▶';
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.2s;
  font-size: 0.8em;
}

.message .content details[open] summary::before {
  transform: rotate(90deg);
}

.message .content details summary:hover {
  background: #e6f2ff;
}

.message .content details pre {
  background: var(--colorNeutralBackground1, #ffffff);
  padding: 14px;
  margin: 0;
  border-top: 1px solid var(--colorNeutralStroke2, #e0e0e0);
  overflow-x: auto;
  font-size: 0.85em;
  line-height: 1.5;
}

.message .content details code {
  background: none;
  color: var(--colorNeutralForeground1, #333);
  font-family: 'Courier New', 'Consolas', monospace;
}

/* Mobile-specific styles */
@media (max-width: 768px) {
  body {
    height: 100dvh; /* Dynamic viewport height - accounts for keyboard */
  }

  .chat-container {
    height: 100dvh;
  }

  .input-area {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: var(--colorNeutralBackground1, white);
  }

  .message {
    margin-bottom: 12px; /* Slightly reduced for mobile */
  }

  .message .content {
    padding: 10px 14px; /* Slightly reduced for mobile */
  }
}

/* Starter Prompts - MS Copilot Style */
.starter-prompts-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 40px;
  width: 100%;
}

.starter-prompts-header {
  text-align: center;
  margin-bottom: 24px;
}

.starter-logo {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  border-radius: 50%;
}

.starter-prompts-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--colorNeutralForeground1, #242424);
  margin: 0;
}

.starter-prompts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 600px;
  width: 100%;
  padding: 0 16px;
}

.starter-prompt-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 16px;
  background: var(--colorNeutralBackground1, white);
  border: 1px solid var(--colorNeutralStroke2, #e0e0e0);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  height: 100%;
}

.starter-prompt-card:hover {
  background: var(--colorNeutralBackground1Hover, #f5f5f5);
  box-shadow: var(--shadow-2, 0 2px 8px rgba(0, 0, 0, 0.08));
  border-color: var(--colorNeutralStroke1, #d1d1d1);
  transform: translateY(-2px);
}

.prompt-icon {
  font-size: 20px;
  margin-bottom: 8px;
}

.prompt-text {
  font-size: 14px;
  color: var(--colorNeutralForeground1, #242424);
  font-weight: 500;
  line-height: 1.4;
}

@media (max-width: 480px) {
  .starter-prompts-grid {
    grid-template-columns: 1fr;
  }
}

/* Full Mode Container (for general GLYDEBuddy chat) */
.acs-chat-full-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: var(--colorNeutralBackground2, #f3f2f1);
}

.acs-chat-full-container .acs-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.acs-chat-full-container .input-area {
  flex-shrink: 0;
}
