/* ai-assistant.css - Styled based on SMFI Nested Actor */

#ai-assistant-wrapper {
  width: 380px;
  height: 100vh;
  flex-shrink: 0;
  border-left: 1px solid #2a2a4a;
  background: #1a1a2e;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.chat-panel {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.chat-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 380px;
}

.chat-header {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid #2a2a4a;
  background: linear-gradient(135deg, #1e1e2f 0%, #1a1a2e 100%);
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-title {
  font-size: 0.875rem;
  font-weight: 900;
  color: #6ee7b7;
  letter-spacing: -0.02em;
  margin: 0;
}

.chat-subtitle {
  font-size: 10px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.125rem;
  margin-bottom: 0;
}

.close-btn {
  background: transparent;
  border: none;
  color: #475569;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s;
  flex-shrink: 0;
}

.close-btn:hover {
  color: #94a3b8;
}

/* Collapsed AI panel — shows as a thin clickable tab */
#ai-assistant-wrapper.collapsed {
  width: 28px;
  cursor: pointer;
  overflow: hidden;
}

#ai-assistant-wrapper.collapsed .chat-inner {
  opacity: 0;
  pointer-events: none;
}

#ai-assistant-wrapper.collapsed::before {
  content: "⚙ AI";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%) rotate(180deg);
  writing-mode: vertical-rl;
  font-size: 10px;
  font-weight: 700;
  color: #6ee7b7;
  letter-spacing: 0.1em;
  padding: 12px 6px;
  white-space: nowrap;
}

#ai-assistant-wrapper {
  position: relative;
  transition: width 0.25s cubic-bezier(0.4,0,0.2,1);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

.chat-welcome {
  background: #16162a;
  border: 1px solid #2a2a4a;
  border-radius: 0.75rem;
  padding: 0.75rem;
  font-size: 12px;
  color: #6ee7b7;
  line-height: 1.5;
}

.ai-message {
  max-width: 88%;
  padding: 0.6rem 0.85rem;
  border-radius: 0.875rem;
  font-size: 13px;
  line-height: 1.55;
  word-wrap: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.ai-user {
  align-self: flex-end;
  background: #6366f1;
  color: white;
  border-bottom-right-radius: 0.2rem;
}

.ai-assistant {
  align-self: flex-start;
  background: #16162a;
  color: #e0e0e0;
  border-bottom-left-radius: 0.2rem;
}

.ai-assistant strong {
  color: #a5b4fc;
}

/* Typing Indicator */
.typing {
  font-style: italic;
  color: #94a3b8;
  animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.5;
  }

  50% {
    opacity: 1;
  }
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 5px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
  background: #4a4a6a;
  border-radius: 10px;
}

.chat-input-area {
  padding: 0.75rem;
  border-top: 1px solid #2a2a4a;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  background: #1a1a2e;
}

.chat-input {
  flex: 1;
  border: 1px solid #2a2a4a;
  background: #16162a;
  color: #e0e0e0;
  border-radius: 0.75rem;
  padding: 0.6rem 0.75rem;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.4;
  min-height: 40px;
  max-height: 120px;
  transition: all 0.2s;
}

.chat-input:focus {
  border-color: #6ee7b7;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 0.75rem;
  border: none;
  background: #10b981;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

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

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

/* Light Theme Overrides */
body.theme-light #ai-assistant-wrapper {
  background: white;
  border-left: 1px solid #e2e8f0;
}

body.theme-light .chat-header {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid #e2e8f0;
}

body.theme-light .chat-title {
  color: #059669;
}

body.theme-light .chat-subtitle {
  color: #64748b;
}

body.theme-light .chat-welcome {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #059669;
}

body.theme-light .ai-assistant {
  background: #f1f5f9;
  color: #1e293b;
}

body.theme-light .ai-assistant strong {
  color: #4f46e5;
}

body.theme-light .chat-input-area {
  background: white;
  border-top: 1px solid #e2e8f0;
}

body.theme-light .chat-input {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #1e293b;
}

body.theme-light .chat-input:focus {
  border-color: #10b981;
}