/**
 * ManiBot AI Assistant Widget Styles
 * Floating chat widget for personalized trading guidance
 */

.assistant-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.assistant-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.assistant-fab:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
}

.assistant-fab:active {
  transform: scale(0.95);
}

.assistant-fab .material-icons {
  font-size: 28px;
}

.assistant-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

.assistant-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: assistantPanelOpen 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes assistantPanelOpen {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.assistant-panel.hidden {
  display: none;
}

.assistant-header {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 16px 16px 0 0;
}

.assistant-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.assistant-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.assistant-title-group h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.assistant-title-group p {
  margin: 2px 0 0 0;
  font-size: 12px;
  opacity: 0.9;
}

.assistant-header-actions {
  display: flex;
  gap: 8px;
}

.assistant-header-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.assistant-header-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.assistant-header-btn .material-icons {
  font-size: 18px;
}

.assistant-quick-actions {
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow-x: visible;
}

.assistant-quick-action {
  flex-shrink: 0;
  padding: 8px 16px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.assistant-quick-action:hover {
  background: var(--theme-primary);
  color: white;
  border-color: var(--theme-primary);
}

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

.assistant-message {
  display: flex;
  gap: 12px;
  animation: messageSlideIn 0.3s ease-out;
}

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

.assistant-message.user {
  flex-direction: row-reverse;
}

.assistant-message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.assistant-message.assistant .assistant-message-avatar {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
}

.assistant-message.user .assistant-message-avatar {
  background: #cbd5e1;
  color: #475569;
}

.assistant-message-content {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.assistant-message.assistant .assistant-message-content {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

.assistant-message.user .assistant-message-content {
  background: #2563eb;
  color: white;
  border-bottom-right-radius: 4px;
}

.assistant-message-time {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 4px;
}

.assistant-typing {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

.assistant-typing-dot {
  width: 8px;
  height: 8px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typingDot 1.4s infinite;
}

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

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

@keyframes typingDot {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-10px);
  }
}

.assistant-input-container {
  padding: 16px;
  background: white;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.assistant-input-wrapper {
  flex: 1;
  position: relative;
}

.assistant-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 24px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  transition: border-color 0.2s;
}

.assistant-input:focus {
  outline: none;
  border-color: var(--theme-primary);
}

.assistant-send-btn {
  width: 40px;
  height: 40px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.assistant-send-btn:hover:not(:disabled) {
  background: #1d4ed8;
  transform: scale(1.05);
}

.assistant-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

/* Voice input button */
.assistant-voice-btn {
  width: 40px;
  height: 40px;
  background: #10b981;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  margin-right: 8px;
}

.assistant-voice-btn:hover {
  background: #059669;
  transform: scale(1.05);
}

.assistant-voice-btn.listening {
  background: #ef4444;
  animation: pulse 1s infinite;
}

.assistant-voice-btn .material-icons {
  font-size: 20px;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
}

/* Voice controls */
.assistant-voice-controls {
  padding: 8px 16px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
}

.voice-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: #64748b;
}

.voice-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #2563eb;
}

.voice-toggle .material-icons {
  font-size: 16px;
}

/* Voice mode toggle */
.voice-mode-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.voice-mode-label {
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
}

.voice-mode-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: white;
  color: #64748b;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.voice-mode-btn .material-icons {
  font-size: 14px;
}

.voice-mode-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.voice-mode-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: white;
}

.voice-mode-btn.active:hover {
  background: #1d4ed8;
}

.assistant-attach-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: none;
  background: #f3f4f6;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.assistant-attach-btn:hover {
  background: #e5e7eb;
  color: #374151;
}

.assistant-attachments {
  padding: 0 16px 8px;
  background: white;
  border-top: 1px solid #e2e8f0;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f3f4f6;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.attachment-item:last-child {
  margin-bottom: 0;
}

.attachment-item .material-icons {
  font-size: 16px;
  color: #6b7280;
}

.attachment-name {
  flex: 1;
  font-weight: 500;
  color: #374151;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-size {
  color: #6b7280;
  font-size: 12px;
}

.attachment-remove {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s;
}

.attachment-remove:hover {
  background: #e5e7eb;
  color: var(--theme-error);
}

.attachment-remove .material-icons {
  font-size: 16px;
}

.assistant-send-btn .material-icons {
  font-size: 20px;
}

.assistant-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 40px;
  text-align: center;
  color: #64748b;
}

.assistant-empty-state .material-icons {
  font-size: 64px;
  color: #cbd5e1;
  margin-bottom: 16px;
}

.assistant-empty-state h4 {
  margin: 0 0 8px 0;
  color: #1e293b;
  font-size: 18px;
  font-weight: 600;
}

.assistant-empty-state p {
  margin: 0 0 24px 0;
  font-size: 14px;
  line-height: 1.6;
}

.assistant-empty-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 280px;
}

.assistant-suggestion {
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  color: #475569;
}

.assistant-suggestion:hover {
  background: #f1f5f9;
  border-color: #2563eb;
  color: #2563eb;
}

/* Speedometer Widget */
.speedometer-widget {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 16px;
  padding: 20px;
  margin: 12px 0;
  border: 2px solid #e2e8f0;
}

.speedometer-title {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
  text-align: center;
  margin-bottom: 20px;
}

.speedometer-gauge {
  position: relative;
  width: 200px;
  height: 120px;
  margin: 0 auto 24px;
}

.speedometer-arc {
  position: absolute;
  width: 200px;
  height: 100px;
  border: 12px solid #e2e8f0;
  border-bottom: none;
  border-radius: 200px 200px 0 0;
  overflow: hidden;
}

.speedometer-arc::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    #ef4444 0%, 
    #f59e0b 25%, 
    #3b82f6 50%, 
    #10b981 100%
  );
  border-radius: 200px 200px 0 0;
}

.speedometer-needle {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 4px;
  height: 80px;
  transform-origin: bottom center;
  border-radius: 4px 4px 0 0;
  transition: transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
}

.speedometer-center {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  background: #1e293b;
  border-radius: 50%;
  border: 3px solid white;
  z-index: 3;
}

.speedometer-score {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 32px;
  font-weight: 800;
  z-index: 1;
}

.speedometer-score span {
  font-size: 16px;
  font-weight: 600;
  color: #64748b;
}

.speedometer-breakdown {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.breakdown-label {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  min-width: 90px;
}

.breakdown-bar {
  flex: 1;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.breakdown-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease-out;
}

.breakdown-score {
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  min-width: 40px;
  text-align: right;
}

.speedometer-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.stat-pill {
  padding: 6px 12px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  color: #475569;
}

@media (max-width: 480px) {
  .assistant-container {
    bottom: 16px;
    right: 16px;
  }
  
  .assistant-panel {
    position: fixed;
    width: calc(100vw - 32px);
    height: calc(100vh - 140px);
    bottom: 80px;
    top: auto;
    left: 16px;
    right: 16px;
    max-height: calc(100vh - 160px);
    /* Account for iOS safe area at top */
    padding-top: env(safe-area-inset-top, 0px);
  }
  
  .assistant-header {
    /* Ensure header is always visible and touchable on mobile */
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 60px;
    padding: 12px 16px;
    flex-shrink: 0;
  }
  
  .assistant-header-btn {
    /* Larger touch target for mobile close button */
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  
  .assistant-header-btn .material-icons {
    font-size: 24px;
  }
  
  .assistant-message-content {
    max-width: 85%;
  }
  
  .speedometer-widget {
    padding: 16px;
  }
  
  .speedometer-gauge {
    width: 160px;
    height: 100px;
  }
  
  .speedometer-arc {
    width: 160px;
    height: 80px;
  }
  
  .speedometer-needle {
    height: 64px;
  }
  
  .speedometer-score {
    font-size: 24px;
  }
  
  .breakdown-label {
    min-width: 70px;
    font-size: 12px;
  }
}

/* Tetris Game Styles */
#tetrisGame {
  display: none;
  padding: 24px;
  background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 100%);
  min-height: calc(100vh - 64px);
  overflow: auto;
}

#tetrisGame.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.tetris-container {
  max-width: 900px;
  width: 100%;
}

.tetris-header {
  text-align: center;
  margin-bottom: 32px;
}

.tetris-title {
  font-size: 48px;
  font-weight: 800;
  color: #00BCD4;
  text-shadow: 0 0 20px rgba(0, 188, 212, 0.5);
  margin-bottom: 8px;
  font-family: 'Courier New', monospace;
}

.tetris-subtitle {
  font-size: 14px;
  color: #94a3b8;
}

.tetris-main {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

.tetris-left {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tetris-stats {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  min-width: 150px;
}

.stat-item {
  margin-bottom: 16px;
}

.stat-item:last-child {
  margin-bottom: 0;
}

.stat-label {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: #00BCD4;
  font-family: 'Courier New', monospace;
}

.tetris-next {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.next-label {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

#nextPieceCanvas {
  border-radius: 8px;
}

.tetris-center {
  position: relative;
}

#tetrisCanvas {
  border: 2px solid rgba(0, 188, 212, 0.3);
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(0, 188, 212, 0.2);
}

.tetris-game-over {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 14, 39, 0.95);
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
}

.game-over-text {
  font-size: 40px;
  font-weight: 800;
  color: #F44336;
  text-shadow: 0 0 20px rgba(244, 67, 54, 0.5);
  font-family: 'Courier New', monospace;
}

.tetris-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.tetris-controls {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  min-width: 200px;
}

.control-title {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: 16px;
}

.control-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #cbd5e1;
}

.control-item:last-child {
  margin-bottom: 0;
}

.control-key {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  font-family: 'Courier New', monospace;
  font-weight: 600;
  font-size: 12px;
  color: #00BCD4;
  min-width: 50px;
  text-align: center;
}

.control-desc {
  flex: 1;
}

.tetris-btn {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

.tetris-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.tetris-btn:active {
  transform: translateY(0);
}

@media (max-width: 768px) {
  .tetris-title {
    font-size: 36px;
  }
  
  .tetris-main {
    flex-direction: column;
    align-items: center;
  }
  
  .tetris-left,
  .tetris-right {
    width: 100%;
    max-width: 300px;
  }
  
  #tetrisCanvas {
    max-width: 100%;
    height: auto;
  }
}

/* Processing/Loading Message Styles */
.processing-indicator {
  display: flex;
  justify-content: center;
  padding: 8px 16px;
}

.processing-message {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  color: #0369a1;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid #bae6fd;
  box-shadow: 0 2px 8px rgba(3, 105, 161, 0.1);
}

.processing-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #bae6fd;
  border-top-color: #0369a1;
  border-radius: 50%;
  animation: processingSpinner 0.8s linear infinite;
}

@keyframes processingSpinner {
  to {
    transform: rotate(360deg);
  }
}

.processing-text {
  animation: processingPulse 1.5s ease-in-out infinite;
}

@keyframes processingPulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}
