/**
 * TWAI Chat Client Styles
 */

.chat-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #1a1a27 0%, #16213e 100%);
  color: #e0e0e0;
  z-index: 1000;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
}

/* ===== Header ===== */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background: linear-gradient(90deg, #0f3460 0%, #1a5276 100%);
  border-bottom: 2px solid #A6E22E;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.chat-header h2 {
  margin: 0;
  font-size: 1.3rem;
  color: #A6E22E;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  background: rgba(16, 163, 127, 0.15);
  color: #A6E22E;
  font-weight: 500;
}

.connection-status.connecting {
  background: rgba(255, 193, 7, 0.15);
  color: #ffc107;
}

.connection-status.disconnected,
.connection-status.error {
  background: rgba(244, 67, 54, 0.15);
  color: #f44336;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.participant-count {
  font-size: 0.9rem;
  color: #b0b0b0;
}

.btn-close {
  background: none;
  border: none;
  color: #e0e0e0;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  transition: color 0.2s;
}

.btn-close:hover {
  color: #f44336;
}

/* ===== Error Banner ===== */
.error-banner {
  background: rgba(244, 67, 54, 0.1);
  border-left: 3px solid #f44336;
  color: #ff9999;
  padding: 0.8rem 1rem;
  font-size: 0.9rem;
}

/* ===== Chat Content ===== */
.chat-content {
  display: flex;
  flex: 1;
  min-height: 0;
  gap: 0;
}

.messages-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1.5rem;
  background: linear-gradient(180deg, #1a1a27 0%, #0f1419 100%);
}

.no-messages {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #666;
  font-style: italic;
}

/* ===== Message Bubbles ===== */
.message-bubble {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
  max-width: 75%;
  word-wrap: break-word;
}

.message-bubble.own {
  align-self: flex-end;
  margin-left: auto;
}

.message-bubble.other {
  align-self: flex-start;
  margin-right: auto;
}

.message-bubble.system {
  align-self: center;
  max-width: 90%;
  margin: 1rem auto;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  margin-bottom: 0.3rem;
}

.message-author {
  font-weight: 600;
  color: #A6E22E;
}

.message-time {
  color: #888;
  margin-left: 0.5rem;
}

.message-bubble.own .message-author {
  color: #7fd9ff;
}

.message-content {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  background: #2a2a3e;
  color: #e0e0e0;
  line-height: 1.5;
  word-break: break-word;
}

.message-bubble.own .message-content {
  background: linear-gradient(135deg, #A6E22E 0%, #0d8a66 100%);
  color: white;
}

.message-bubble.system .message-content {
  background: transparent;
  color: #888;
  font-style: italic;
  text-align: center;
  padding: 0.5rem;
}

/* ===== Typing Indicator ===== */
.typing-indicator-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.typing-indicator {
  display: flex;
  gap: 3px;
  align-items: center;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: #888;
  border-radius: 50%;
  animation: bounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {
  0%, 80%, 100% {
    opacity: 0.5;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-8px);
  }
}

.typing-text {
  font-size: 0.85rem;
  color: #888;
  font-style: italic;
  margin: 0;
}

/* ===== Participants Sidebar ===== */
.participants-sidebar {
  width: 200px;
  background: #0f1419;
  border-left: 1px solid #2a2a3e;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.participants-header {
  padding: 1rem;
  font-weight: 600;
  color: #A6E22E;
  border-bottom: 1px solid #2a2a3e;
}

.participants-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.participant-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  border-radius: 8px;
  background: rgba(16, 163, 127, 0.05);
  transition: background 0.2s;
  cursor: pointer;
}

.participant-item:hover {
  background: rgba(16, 163, 127, 0.15);
}

.participant-item.own {
  background: rgba(16, 163, 127, 0.1);
  border: 1px solid rgba(16, 163, 127, 0.3);
}

.participant-avatar {
  font-size: 1.2rem;
  text-align: center;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.participant-info {
  flex: 1;
  min-width: 0;
}

.participant-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.participant-status {
  font-size: 0.75rem;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.participant-item.own .participant-status {
  color: #A6E22E;
}

/* ===== Input Area ===== */
.input-area {
  display: flex;
  gap: 0.5rem;
  padding: 1rem;
  background: #0f1419;
  border-top: 1px solid #2a2a3e;
  min-height: 60px;
}

.message-input {
  flex: 1;
  background: #1a1a27;
  border: 1px solid #2a2a3e;
  color: #e0e0e0;
  padding: 0.75rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  max-height: 100px;
  transition: border-color 0.2s;
}

.message-input:focus {
  outline: none;
  border-color: #A6E22E;
  box-shadow: 0 0 0 2px rgba(16, 163, 127, 0.2);
}

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

.btn-send {
  background: linear-gradient(135deg, #A6E22E 0%, #0d8a66 100%);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  min-width: 80px;
}

.btn-send:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-send:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Scrollbar Styling ===== */
.messages-area::-webkit-scrollbar,
.participants-list::-webkit-scrollbar {
  width: 6px;
}

.messages-area::-webkit-scrollbar-track,
.participants-list::-webkit-scrollbar-track {
  background: transparent;
}

.messages-area::-webkit-scrollbar-thumb,
.participants-list::-webkit-scrollbar-thumb {
  background: rgba(16, 163, 127, 0.3);
  border-radius: 3px;
}

.messages-area::-webkit-scrollbar-thumb:hover,
.participants-list::-webkit-scrollbar-thumb:hover {
  background: rgba(16, 163, 127, 0.5);
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .chat-content {
    flex-direction: column;
  }

  .participants-sidebar {
    width: 100%;
    height: 150px;
    border-left: none;
    border-top: 1px solid #2a2a3e;
  }

  .message-bubble {
    max-width: 85%;
  }

  .chat-header h2 {
    font-size: 1.1rem;
  }

  .header-right {
    gap: 1rem;
  }

  .participant-count {
    display: none;
  }
}

@media (max-width: 480px) {
  .chat-container {
    position: absolute;
  }

  .chat-header {
    padding: 0.75rem;
  }

  .messages-area {
    padding: 1rem;
  }

  .message-bubble {
    max-width: 95%;
  }

  .input-area {
    flex-direction: column;
  }

  .btn-send {
    width: 100%;
  }

  .connection-status {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
  }
}

/* ===== AI Assistant Message Styling ===== */
.message-bubble.ai {
  align-self: flex-start;
  max-width: 75%;
  margin: 0.5rem 0;
}

.message-bubble.ai .message-author {
  color: #A6E22E !important;
  font-weight: 700;
}

.message-bubble.ai .message-content {
  background: linear-gradient(135deg, #A6E22E 0%, #0d8a66 100%);
  color: white;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ===== Broadcast Message Styling ===== */
.message-bubble.broadcast {
  align-self: center;
  max-width: 90%;
  margin: 1rem auto;
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.15) 0%, rgba(166, 226, 46, 0.1) 100%);
  border: 1px solid rgba(166, 226, 46, 0.3);
  border-radius: 12px;
  padding: 1rem;
}

.message-bubble.broadcast .message-author {
  color: #FFC107 !important;
  font-weight: 700;
  font-size: 0.9rem;
}

.message-bubble.broadcast .message-content {
  background: transparent;
  color: #e0e0e0;
  padding: 0.75rem 0;
  border: none;
  text-align: left;
}

.message-bubble.broadcast .message-content strong {
  color: #FFD54F;
  font-weight: 700;
}

/* ===== Guest AI Disabled Notification ===== */
.guest-ai-notification {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  margin-bottom: 1rem;
  background: rgba(255, 193, 7, 0.1);
  border-left: 3px solid #FFC107;
  border-radius: 4px;
  color: #FFD54F;
  font-size: 0.9rem;
  text-align: center;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== Dark Theme (Default) ===== */
:root {
  --bg-primary: #1a1a27;
  --bg-secondary: #0f1419;
  --bg-tertiary: #2a2a3e;
  --text-primary: #e0e0e0;
  --text-secondary: #888;
  --accent-primary: #A6E22E;
  --accent-secondary: #7fd9ff;
}

/* ===== Light Theme (Optional) ===== */
@media (prefers-color-scheme: light) {
  .chat-container {
    background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
    color: #333;
  }

  .chat-header {
    background: linear-gradient(90deg, #e0e0e0 0%, #d0d0d0 100%);
    border-bottom-color: #A6E22E;
  }

  .message-input {
    background: white;
    color: #333;
    border-color: #ddd;
  }

  .message-content {
    background: #f0f0f0;
    color: #333;
  }

  .message-bubble.own .message-content {
    background: linear-gradient(135deg, #A6E22E 0%, #0d8a66 100%);
    color: white;
  }

  .message-bubble.ai .message-content {
    background: linear-gradient(135deg, #A6E22E 0%, #0d8a66 100%);
    color: white;
  }

  .guest-ai-notification {
    background: rgba(255, 193, 7, 0.15);
    border-left-color: #FFC107;
    color: #FF9800;
  }

  .participants-sidebar {
    background: #f5f5f5;
    border-left-color: #ddd;
  }

  .input-area {
    background: #f5f5f5;
    border-top-color: #ddd;
  }
}
