/* ==========================================================================
   ECHO TERMINAL WIDGET CSS STYLES
   ========================================================================== */

/* Terminal Custom Fonts & Monospace Stack */
.echo-terminal-font {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Floating Action Button (FAB) */
.echo-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--btn-primary-bg);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 99999;
  box-shadow: var(--btn-primary-shadow);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.echo-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 0 25px var(--accent-2-color);
}

.echo-fab i {
  font-size: 20px;
  transition: transform 0.3s ease;
}

/* Pulsing Glow Animation for FAB */
@keyframes echo-pulse-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 180, 216, 0.5);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(0, 180, 216, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 180, 216, 0);
  }
}

.echo-fab-pulse {
  animation: echo-pulse-glow 2s infinite;
}

/* Tooltip for FAB button */
.echo-tooltip {
  position: fixed;
  bottom: 34px;
  right: 88px;
  background: var(--surface-color-2);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  z-index: 99998;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  opacity: 1;
  transform: translateX(0);
}

.echo-tooltip::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -5px;
  width: 8px;
  height: 8px;
  background: var(--surface-color-2);
  border-right: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
  transform: translateY(-50%) rotate(45deg);
}

.echo-tooltip.hidden {
  opacity: 0;
  transform: translateX(8px);
}

/* Terminal Window Container */
.echo-window {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 560px;
  height: 580px;
  max-height: calc(100vh - 140px);
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  z-index: 99998;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.9) translateY(20px);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Open State */
.echo-window.open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* macOS style header */
.echo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background-color: var(--surface-color-2);
  border-bottom: 1px solid var(--border-color);
}

.echo-dots {
  display: flex;
  gap: 8px;
}

.echo-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.echo-dot-red { background-color: #ff5f56; }
.echo-dot-yellow { background-color: #ffbd2e; }
.echo-dot-green { background-color: #27c93f; }

.echo-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.echo-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.echo-close-btn:hover {
  color: var(--text-primary);
}

/* Messages Area */
.echo-messages-container {
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background-color: var(--surface-color);
  scrollbar-width: thin;
}

/* Monospace Box style for all messages */
.echo-message-box {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px;
  background-color: var(--surface-color-2);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  word-break: break-word;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Animations for new messages */
@keyframes echo-slide-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.echo-msg-new {
  animation: echo-slide-up 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Message labels */
.echo-label-welcome {
  color: var(--accent-2-color);
  font-weight: bold;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.echo-label-user {
  color: var(--accent-2-color);
  font-weight: bold;
}

.echo-label-ai {
  color: var(--success-color);
  font-weight: bold;
}

/* User Box Specific */
.echo-message-box.user-box {
  background-color: rgba(0, 180, 216, 0.04);
  border-color: rgba(0, 180, 216, 0.15);
}

/* AI Box Specific */
.echo-message-box.ai-box {
  background-color: rgba(16, 185, 129, 0.03);
  border-color: rgba(16, 185, 129, 0.12);
}

/* Typing / Thinking Cursor */
.echo-cursor {
  display: inline-block;
  width: 8px;
  height: 15px;
  background-color: var(--success-color);
  margin-left: 4px;
  vertical-align: middle;
  animation: echo-blink 1s infinite;
}

@keyframes echo-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Input Area at Bottom */
.echo-input-area {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  background-color: var(--surface-color-2);
}

.echo-input-row {
  display: flex;
  align-items: flex-end;
  position: relative;
}

.echo-textarea {
  width: 100%;
  min-height: 44px;
  max-height: 120px;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px 50px 12px 14px;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color var(--transition-fast);
}
.echo-message-box
.echo-textarea:focus {
  caret-color: var(--accent-2-color);
  border-color: var(--accent-2-color);
  box-shadow: 0 0 0 1px var(--accent-2-color);
}

.echo-send-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background-color: var(--accent-2-color);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.echo-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  opacity: 0.95;
}

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

.echo-input-hints {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  padding: 0 4px;
  font-size: 10px;
  color: var(--text-muted);
}

/* Suggested Questions Chips */
.echo-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.echo-chip {
  background-color: var(--surface-color-2);
  border: 1px solid var(--accent-2-color);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 12px;
  font-family: inherit;
  color: var(--accent-2-color);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  white-space: nowrap;
}

.echo-chip:hover {
  background-color: var(--accent-2-color);
  border-color: var(--accent-2-color);
  color: #ffffff;
}

/* Scrollbar customization for messages */
.echo-messages-container::-webkit-scrollbar {
  width: 6px;
}

.echo-messages-container::-webkit-scrollbar-track {
  background: var(--surface-color);
}

.echo-messages-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* Mobile responsive styling (Bottom Sheet) */
@media (max-width: 768px) {
  .echo-fab {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
  }
  
  .echo-window {
    width: 100%;
    height: 75vh;
    max-height: 75vh;
    bottom: 0;
    right: 0;
    border-radius: 16px 16px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    transform: translateY(100%);
  }

  .echo-window.open {
    transform: translateY(0);
  }
  
  .echo-header {
    padding: 16px;
  }

  .echo-tooltip {
    display: none;
  }
}

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .echo-fab-pulse {
    animation: none;
  }
  .echo-fab:hover {
    transform: none;
  }
  .echo-window {
    transition: opacity 0.1s linear;
    transform: none !important;
  }
  .echo-msg-new {
    animation: none;
  }
  .echo-cursor {
    animation: none;
  }
}
