/**
 * ROUGESWORLD - Oracle Chat System
 * Styling for the Matrix-themed AI assistant
 */

/* Oracle Container */
.oracle-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: var(--z-oracle);
}

/* Oracle Trigger Button */
.oracle-trigger {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--matrix-green) 0%, var(--matrix-green-dim) 100%);
  border: none;
  color: var(--bg-primary);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--matrix-green-glow);
  position: relative;
  z-index: 2;
  transition: all var(--transition-smooth);
}

.oracle-trigger:hover {
  transform: scale(1.05);
  box-shadow: 0 0 30px var(--matrix-green-glow);
}

.oracle-trigger:active {
  transform: scale(0.95);
}

/* Oracle Pulse Animation */
.oracle-pulse {
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  border: 2px solid var(--matrix-green);
  opacity: 0;
  animation: oracle-pulse 2s infinite;
}

@keyframes oracle-pulse {
  0% {
    transform: scale(1);
    opacity: 0.7;
  }
  70% {
    transform: scale(1.1);
    opacity: 0;
  }
  100% {
    transform: scale(1.1);
    opacity: 0;
  }
}

/* Oracle Chat Window */
.oracle-chat {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 350px;
  height: 450px;
  background-color: rgba(0, 0, 0, 0.9);
  border: 1px solid var(--matrix-green);
  border-radius: 10px;
  box-shadow: 0 0 20px var(--matrix-green-glow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0);
  transform-origin: bottom right;
  transition: transform var(--transition-bounce);
  opacity: 0;
  visibility: hidden;
}

.oracle-chat[aria-hidden="false"] {
  transform: scale(1);
  opacity: 1;
  visibility: visible;
}

/* Oracle Chat Header */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background-color: rgba(0, 40, 0, 0.5);
  border-bottom: 1px solid var(--matrix-green-dim);
}

.chat-title {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  color: var(--matrix-green);
  margin: 0;
  text-shadow: 0 0 10px var(--matrix-green-glow);
}

.chat-close {
  background: transparent;
  border: none;
  color: var(--matrix-green);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all var(--transition-fast);
}

.chat-close:hover {
  background-color: rgba(0, 255, 0, 0.1);
  box-shadow: 0 0 10px var(--matrix-green-glow);
}

/* Chat Messages Container */
.chat-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--matrix-green-dim) var(--bg-secondary);
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.chat-messages::-webkit-scrollbar-thumb {
  background-color: var(--matrix-green-dim);
  border-radius: 20px;
}

/* Message Bubbles */
.message {
  max-width: 80%;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  font-family: var(--font-matrix);
  font-size: var(--text-sm);
  line-height: 1.4;
  position: relative;
  flex-shrink: 0;               /* le bolle non si comprimono: il contenitore scrolla */
  animation: message-appear 0.3s ease-out forwards;
}

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

.oracle-message {
  align-self: flex-start;
  background-color: rgba(0, 40, 0, 0.5);
  border: 1px solid var(--matrix-green-dim);
  color: var(--text-primary);
  border-bottom-left-radius: 0;
}

.user-message {
  align-self: flex-end;
  background-color: rgba(0, 60, 0, 0.5);
  border: 1px solid var(--matrix-green);
  color: var(--text-primary);
  border-bottom-right-radius: 0;
}

/* Matrix Style for Oracle Messages */
.oracle-message.matrix-style {
  position: relative;
  overflow: hidden;
}

.oracle-message.matrix-style::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 255, 0, 0.1) 50%,
    transparent 100%
  );
  animation: message-scan 2s linear infinite;
  pointer-events: none;
}

@keyframes message-scan {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  background-color: rgba(0, 40, 0, 0.5);
  border: 1px solid var(--matrix-green-dim);
  border-radius: 10px;
  border-bottom-left-radius: 0;
  align-self: flex-start;
  margin-top: 0.5rem;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background-color: var(--matrix-green);
  border-radius: 50%;
  opacity: 0.6;
  animation: typing-dot 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing-dot {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.6;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Chat Input Container */
.chat-input-container {
  display: flex;
  align-items: center;
  padding: 1rem;
  background-color: rgba(0, 20, 0, 0.7);
  border-top: 1px solid var(--matrix-green-dim);
}

.chat-input {
  flex: 1;
  background-color: rgba(0, 40, 0, 0.5);
  border: 1px solid var(--matrix-green-dim);
  border-radius: 20px;
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-matrix);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
}

.chat-input:focus {
  outline: none;
  border-color: var(--matrix-green);
  box-shadow: 0 0 10px var(--matrix-green-glow);
}

.chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--matrix-green-dim);
  border: none;
  color: var(--bg-primary);
  font-size: 1.2rem;
  cursor: pointer;
  margin-left: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.chat-send:hover {
  background-color: var(--matrix-green);
  box-shadow: 0 0 10px var(--matrix-green-glow);
}

.chat-send:active {
  transform: scale(0.95);
}

/* Responsive Design */
@media (max-width: 768px) {
  .oracle-chat {
    width: 300px;
    height: 400px;
    bottom: 70px;
  }
  
  .oracle-container {
    bottom: 1.5rem;
    right: 1.5rem;
  }
  
  .oracle-trigger {
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }
}

@media (max-width: 480px) {
  .oracle-chat {
    width: calc(100vw - 40px);
    right: -10px;
  }
  
  .oracle-container {
    bottom: 1rem;
    right: 1rem;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .oracle-pulse {
    animation: none;
  }
  
  .oracle-chat {
    transition: none;
  }
  
  .message {
    animation: none;
  }
  
  .typing-dot {
    animation: none;
  }
  
  .oracle-message.matrix-style::before {
    animation: none;
  }
}