/* AI Chat Widget Styles */

/* Floating trigger button */
.ai-chat-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold, #d4a843), #b8922e);
  border: none;
  color: #0f0f12;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(212, 168, 67, 0.45);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.ai-chat-trigger:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 32px rgba(212, 168, 67, 0.55);
}

.ai-chat-trigger .material-icons {
  font-size: 30px;
}

/* Chat panel */
.ai-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 460px;
  max-height: 720px;
  background: #1a1a22;
  border: 1px solid rgba(212, 168, 67, 0.25);
  border-radius: 16px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 56px rgba(0, 0, 0, 0.65);
  overflow: hidden;
  animation: ai-chat-slide-up 0.25s ease-out;
}

@keyframes ai-chat-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #15151d;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-chat-title {
  font-size: 1rem;
  font-weight: 600;
  color: #ededf3;
}

.ai-chat-header-actions {
  display: flex;
  gap: 4px;
}

.ai-chat-header-btn {
  background: none;
  border: none;
  color: #8888a0;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}

.ai-chat-header-btn:hover {
  color: #ededf3;
  background: rgba(255, 255, 255, 0.08);
}

.ai-chat-header-btn .material-icons {
  font-size: 22px;
}

/* Messages area */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 350px;
  max-height: 500px;
}

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

.ai-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}

/* Welcome message */
.ai-chat-welcome {
  text-align: center;
  padding: 32px 20px;
  color: #b0b0c4;
  font-size: 0.95rem;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: auto 0;
}

/* Message bubbles */
.ai-msg {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.ai-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(212, 168, 67, 0.2), rgba(212, 168, 67, 0.12));
  color: #ededf3;
  border: 1px solid rgba(212, 168, 67, 0.18);
}

.ai-msg-assistant {
  align-self: flex-start;
  background: #24243a;
  color: #dddde8;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Markdown in messages */
.ai-msg-assistant strong {
  color: #ededf3;
  font-weight: 600;
}

.ai-msg-assistant em {
  color: #c4c4d8;
}

.ai-msg-assistant code {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.ai-msg-assistant a {
  color: var(--gold, #d4a843);
  text-decoration: none;
}

.ai-msg-assistant a:hover {
  text-decoration: underline;
}

/* Lists in assistant messages */
.ai-msg-assistant ul,
.ai-msg-assistant ol {
  margin: 6px 0;
  padding-left: 20px;
}

.ai-msg-assistant li {
  margin-bottom: 4px;
}

/* Tool result cards */
.ai-tool-card {
  background: rgba(52, 199, 89, 0.06);
  border: 1px solid rgba(52, 199, 89, 0.18);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.9rem;
  align-self: flex-start;
  max-width: 92%;
}

.ai-tool-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #8888a0;
  font-weight: 500;
  font-size: 0.82rem;
}

.ai-tool-card-header .material-icons {
  font-size: 16px;
  color: #34c759;
}

/* Error icon override */
.ai-tool-card-header .material-icons:first-child:not(:only-child) {
  color: #34c759;
}

/* When body is present, add spacing */
.ai-tool-card:has(.ai-tool-card-body) {
  padding: 12px 16px;
}

.ai-tool-card:has(.ai-tool-card-body) .ai-tool-card-header {
  margin-bottom: 8px;
  color: var(--gold, #d4a843);
  font-weight: 600;
  font-size: 0.85rem;
}

.ai-tool-card:has(.ai-tool-card-body) .ai-tool-card-header .material-icons {
  font-size: 18px;
}

.ai-tool-card:has(.ai-tool-card-body) {
  background: rgba(212, 168, 67, 0.07);
  border-color: rgba(212, 168, 67, 0.18);
}

/* Running state */
.ai-tool-running {
  background: rgba(212, 168, 67, 0.07);
  border-color: rgba(212, 168, 67, 0.18);
}

.ai-tool-running .ai-tool-card-header {
  color: var(--gold, #d4a843);
}

.ai-tool-spinner {
  animation: ai-spin 1s linear infinite;
  color: var(--gold, #d4a843) !important;
}

@keyframes ai-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Navigation result cards */
.ai-tool-card-nav {
  background: rgba(0, 122, 255, 0.06);
  border-color: rgba(0, 122, 255, 0.18);
}

.ai-tool-card-nav .ai-tool-card-header .material-icons {
  color: #007aff !important;
}

.ai-tool-nav-link {
  color: #5ac8fa;
  text-decoration: none;
  font-weight: 500;
}

.ai-tool-nav-link:hover {
  text-decoration: underline;
}

/* Error result cards */
.ai-tool-card-error {
  background: rgba(239, 68, 68, 0.06);
  border-color: rgba(239, 68, 68, 0.18);
}

.ai-tool-card-error .ai-tool-card-header .material-icons {
  color: #f87171 !important;
}

.ai-tool-card-body {
  color: #c4c4d8;
  line-height: 1.5;
}

.ai-tool-card-body pre {
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.85rem;
  margin: 6px 0;
}

/* Copy button for tokens */
.ai-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(212, 168, 67, 0.15);
  border: 1px solid rgba(212, 168, 67, 0.3);
  color: var(--gold, #d4a843);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
  margin-top: 6px;
  transition: background 0.15s;
}

.ai-copy-btn:hover {
  background: rgba(212, 168, 67, 0.25);
}

.ai-copy-btn .material-icons {
  font-size: 16px;
}

/* Confirmation cards */
.ai-confirm-card {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 10px;
  padding: 14px 16px;
  align-self: flex-start;
  max-width: 92%;
}

.ai-confirm-description {
  color: #dddde8;
  font-size: 0.93rem;
  margin-bottom: 12px;
  line-height: 1.5;
}

.ai-confirm-actions {
  display: flex;
  gap: 10px;
}

.ai-confirm-btn {
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
}

.ai-confirm-btn:hover {
  opacity: 0.85;
}

.ai-confirm-btn-yes {
  background: linear-gradient(135deg, var(--gold, #d4a843), #b8922e);
  color: #0f0f12;
}

.ai-confirm-btn-no {
  background: rgba(255, 255, 255, 0.08);
  color: #9999b0;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Error card */
.ai-error-card {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.9rem;
  color: #f87171;
  align-self: flex-start;
  max-width: 92%;
  line-height: 1.5;
}

/* Typing indicator */
.ai-chat-typing {
  padding: 10px 20px;
}

.typing-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: #b8922e;
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Input form */
.ai-chat-input-form {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #15151d;
}

.ai-chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #24243a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 10px 10px 16px;
  transition: border-color 0.15s;
}

.ai-chat-input-wrapper:focus-within {
  border-color: rgba(212, 168, 67, 0.45);
}

.ai-chat-input {
  flex: 1;
  background: none;
  border: none;
  color: #ededf3;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  max-height: 100px;
  outline: none;
  font-family: inherit;
}

.ai-chat-input::placeholder {
  color: #6a6a80;
}

.ai-chat-send-btn {
  background: linear-gradient(135deg, var(--gold, #d4a843), #b8922e);
  border: none;
  color: #0f0f12;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s;
}

.ai-chat-send-btn:hover {
  opacity: 0.85;
}

.ai-chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

/* Mobile responsive */
@media (max-width: 520px) {
  .ai-chat-panel {
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: none;
  }

  .ai-chat-trigger {
    bottom: 20px;
    right: 20px;
    width: 54px;
    height: 54px;
  }

  .ai-chat-trigger .material-icons {
    font-size: 26px;
  }

  .ai-chat-messages {
    min-height: 0;
    max-height: none;
    flex: 1;
  }
}
