/* CO-Dream Ai Chat - Futurista, Web3, Dark Mode */
.dream-os-chat {
  --chat-bg: rgba(15, 15, 18, 0.92);
  --chat-border: rgba(255, 56, 92, 0.4);
  --chat-glow: rgba(255, 56, 92, 0.35);
  --chat-text: rgba(255, 255, 255, 0.95);
  --chat-text-muted: rgba(255, 255, 255, 0.6);
  --chat-input-bg: rgba(255, 255, 255, 0.06);
  --chat-input-border: rgba(255, 255, 255, 0.12);
  --chat-user-bubble: linear-gradient(135deg, var(--brand-color) 0%, #d9324e 100%);
  --chat-bot-bubble: rgba(255, 255, 255, 0.08);
  --chat-accent: #ff385c;
}

.dream-os-chat {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Circular', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

/* Botón flotante */
.dream-os-trigger {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--chat-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--chat-border);
  box-shadow: 0 0 24px var(--chat-glow), 0 4px 20px rgba(0, 0, 0, 0.4);
  color: var(--chat-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.dream-os-trigger:hover {
  transform: scale(1.05);
  box-shadow: 0 0 32px var(--chat-glow), 0 6px 24px rgba(0, 0, 0, 0.5);
}

.dream-os-trigger i {
  transition: transform 0.3s;
}

.dream-os-chat.is-open .dream-os-trigger i {
  transform: rotate(180deg);
}

/* Ventana del chat */
.dream-os-window {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 0;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 480px;
  max-height: calc(100vh - 140px);
  background: var(--chat-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  box-shadow: 0 0 40px var(--chat-glow), 0 20px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.95);
  transition: opacity 0.25s, transform 0.25s, visibility 0.25s;
}

.dream-os-chat.is-open .dream-os-window {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header */
.dream-os-header {
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--chat-input-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.dream-os-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--chat-accent) 0%, #9945FF 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
}

.dream-os-header-info h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--chat-text);
}

.dream-os-header-info span {
  font-size: 0.75rem;
  color: var(--chat-text-muted);
}

.dream-os-header-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.dream-os-header-actions button {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--chat-text-muted);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.dream-os-header-actions button:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--chat-text);
}

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

.dream-os-message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  animation: dream-os-fade-in 0.3s ease;
}

@keyframes dream-os-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.dream-os-message.user {
  align-self: flex-end;
  background: var(--chat-user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.dream-os-message.bot {
  align-self: flex-start;
  background: var(--chat-bot-bubble);
  color: var(--chat-text);
  border: 1px solid var(--chat-input-border);
  border-bottom-left-radius: 4px;
}

.dream-os-message.bot.typing {
  color: var(--chat-text-muted);
}

.dream-os-message .typing-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-text-muted);
  margin: 0 2px;
  animation: dream-os-bounce 1.4s ease-in-out infinite;
}

.dream-os-message .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.dream-os-message .typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dream-os-bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input */
.dream-os-input-wrap {
  padding: 16px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--chat-input-border);
}

.dream-os-input-inner {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.dream-os-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 12px 16px;
  background: var(--chat-input-bg);
  border: 1px solid var(--chat-input-border);
  border-radius: 12px;
  color: var(--chat-text);
  font-size: 0.9rem;
  resize: none;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.dream-os-input::placeholder {
  color: var(--chat-text-muted);
}

.dream-os-input:focus {
  outline: none;
  border-color: var(--chat-accent);
  box-shadow: 0 0 0 2px rgba(255, 56, 92, 0.2);
}

.dream-os-send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--chat-accent) 0%, #d9324e 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: transform 0.2s, opacity 0.2s;
}

.dream-os-send:hover:not(:disabled) {
  transform: scale(1.05);
}

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

/* Scrollbar */
.dream-os-messages::-webkit-scrollbar {
  width: 6px;
}

.dream-os-messages::-webkit-scrollbar-track {
  background: transparent;
}

.dream-os-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.dream-os-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}
