/* ============================================================
   ai-chat.css — Estilos do Chat com Assistente IA
   Paleta: Fundo profundo, acentos vermelhos, estética sóbria
   ============================================================ */

.ai-chat-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
  gap: 0;
}

/* ── Header da seção ─────────────────────────────────────── */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 0 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

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

.ai-chat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #d32f2f;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-chat-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #f1f1f1;
  margin: 0;
}

.ai-chat-subtitle {
  font-size: 0.78rem;
  color: #6b6b6b;
  margin: 0;
}

.ai-chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-stats-badge {
  font-size: 0.72rem;
  color: #6b6b6b;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  padding: 4px 10px;
}

.btn-clear-chat {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  color: #8a8a8a;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  padding: 6px 12px;
  transition: background 0.15s, color 0.15s;
}

.btn-clear-chat:hover {
  background: rgba(255,255,255,0.05);
  color: #d4d4d4;
}

/* ── Messages Area ──────────────────────────────────────── */
.ai-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.08) transparent;
}

/* Empty state */
.ai-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 12px;
  color: #555;
  text-align: center;
  padding: 2rem;
}

.ai-empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: rgba(211, 47, 47, 0.1);
  border: 1px solid rgba(211, 47, 47, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.ai-empty-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #b0b0b0;
  margin: 0;
}

.ai-empty-desc {
  font-size: 0.85rem;
  color: #666;
  margin: 0;
  max-width: 340px;
  line-height: 1.5;
}

.ai-suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.ai-chip {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  color: #8a8a8a;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 6px 14px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.ai-chip:hover {
  background: rgba(211, 47, 47, 0.08);
  border-color: rgba(211, 47, 47, 0.3);
  color: #ef5350;
}

/* Message bubbles */
.ai-message {
  display: flex;
  gap: 10px;
  animation: msgFadeIn 0.25s ease;
  align-items: flex-end;
}

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

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

.ai-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 2px;
}

.ai-msg-avatar--ai {
  background: #d32f2f;
  color: #fff;
}

.ai-msg-avatar--user {
  background: #333;
  border: 1px solid rgba(255,255,255,0.1);
  color: #ccc;
}

.ai-msg-content {
  max-width: 72%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-message--user .ai-msg-content {
  align-items: flex-end;
}

.ai-message--user .ai-msg-bubble {
  text-align: center;
}

.ai-msg-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.ai-message--ai .ai-msg-bubble {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-bottom-left-radius: 3px;
  color: #e0e0e0;
}

.ai-message--user .ai-msg-bubble {
  background: #d32f2f;
  color: #fff;
  border-bottom-right-radius: 3px;
}

.ai-msg-time {
  font-size: 0.7rem;
  color: #555;
  padding: 0 4px;
}

/* Typing indicator */
.ai-typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-typing-dots {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  border-bottom-left-radius: 3px;
}

.ai-typing-dot {
  width: 6px;
  height: 6px;
  background: #555;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Input Area ─────────────────────────────────────────── */
.ai-input-area {
  padding: 0.875rem 0 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.ai-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 10px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-input-wrapper:focus-within {
  border-color: rgba(211, 47, 47, 0.4);
  box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.06);
}

.ai-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e0e0e0;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  resize: none;
  min-height: 24px;
  max-height: 220px;
  overflow-y: auto;
  padding: 0;
  transition: height 0.1s ease;
}

.ai-textarea::placeholder {
  color: #555;
}

.btn-send {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #d32f2f;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.btn-send:hover:not(:disabled) {
  background: #b71c1c;
  transform: scale(1.04);
}

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

.ai-input-hint {
  font-size: 0.72rem;
  color: #555;
  margin-top: 6px;
  padding-left: 4px;
}

/* ── Botão Deploy Manual ───────────────────────────────── */
.btn-deploy-manual {
  background: #d32f2f;
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 6px 14px;
  transition: background 0.15s;
}

.btn-deploy-manual:hover {
  background: #b71c1c;
}

/* ── Modal Deploy Manual ──────────────────────────────── */
.deploy-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.deploy-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.deploy-modal {
  background: #1a1a1a;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  width: 92vw;
  max-width: 820px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  transform: translateY(16px);
  transition: transform 0.2s ease;
}

.deploy-modal-overlay.open .deploy-modal {
  transform: translateY(0);
}

.deploy-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.deploy-modal-title {
  font-size: 1rem;
  font-weight: 600;
  color: #e0e0e0;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.deploy-modal-title svg {
  color: #d32f2f;
}

.deploy-modal-close {
  background: transparent;
  border: none;
  color: #666;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

.deploy-modal-close:hover {
  background: rgba(255,255,255,0.05);
  color: #ccc;
}

.deploy-modal-body {
  padding: 1rem 1.25rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
  flex: 1;
}

/* Busca */
.deploy-search-box {
  position: relative;
}

.deploy-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #555;
  pointer-events: none;
}

.deploy-search-input {
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  color: #e0e0e0;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 10px 14px 10px 38px;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.deploy-search-input:focus {
  border-color: rgba(211, 47, 47, 0.4);
  box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.06);
}

.deploy-search-input::placeholder {
  color: #555;
}

/* Painéis lado a lado */
.deploy-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.deploy-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 6px;
  background: rgba(0,0,0,0.2);
}

.deploy-panel-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
  padding: 10px 14px 6px;
  flex-shrink: 0;
}

.deploy-server-list,
.deploy-app-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}

/* Server item */
.deploy-server-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s;
  border: 1px solid transparent;
}

.deploy-server-item:hover {
  background: rgba(255,255,255,0.04);
}

.deploy-server-item.selected {
  background: rgba(211, 47, 47, 0.08);
  border-color: rgba(211, 47, 47, 0.25);
}

.deploy-server-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.deploy-server-dot.online   { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.35); }
.deploy-server-dot.offline  { background: #ef4444; }
.deploy-server-dot.maint    { background: #f59e0b; }

.deploy-server-info {
  flex: 1;
  min-width: 0;
}

.deploy-server-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deploy-server-host {
  font-size: 0.7rem;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deploy-server-badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 3px;
  background: rgba(211, 47, 47, 0.1);
  color: #ef5350;
  flex-shrink: 0;
  font-weight: 500;
}

/* App item */
.deploy-app-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.05);
  margin-bottom: 6px;
  transition: border-color 0.12s;
}

.deploy-app-item:hover {
  border-color: rgba(211, 47, 47, 0.2);
}

.deploy-app-info {
  flex: 1;
  min-width: 0;
}

.deploy-app-name {
  font-size: 0.82rem;
  font-weight: 500;
  color: #e0e0e0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deploy-app-meta {
  font-size: 0.7rem;
  color: #666;
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.deploy-app-meta span {
  white-space: nowrap;
}

.btn-deploy-app {
  background: #d32f2f;
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 5px 14px;
  flex-shrink: 0;
  transition: background 0.12s;
}

.btn-deploy-app:hover {
  background: #b71c1c;
}

/* Placeholders / loading / empty */
.deploy-loading,
.deploy-placeholder,
.deploy-no-results {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #555;
  font-size: 0.8rem;
  text-align: center;
  padding: 2rem 1rem;
  height: 100%;
}

.deploy-loading::before {
  content: '';
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255,255,255,0.06);
  border-top-color: #d32f2f;
  border-radius: 50%;
  animation: deploySpin 0.7s linear infinite;
}

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

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 640px) {
  .ai-chat-layout { padding: 0 1rem; }
  .ai-msg-content { max-width: 88%; }
  .ai-chat-subtitle { display: none; }
  .deploy-panels { grid-template-columns: 1fr; }
  .deploy-modal { max-height: 90vh; }
}

/* ── Streaming cursor ────────────────────────────────────── */
.ai-msg-streaming::after {
  content: '▋';
  display: inline-block;
  animation: blink 0.8s step-end infinite;
  color: var(--accent, #6366f1);
  margin-left: 2px;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }

/* ── Tool indicator ──────────────────────────────────────── */
.ai-tool-indicator {
  font-size: 12px;
  color: var(--text-secondary, #888);
  padding: 6px 14px;
  margin: 4px 0;
  background: var(--bg-secondary, #f5f5f5);
  border-radius: 8px;
  display: inline-block;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

/* ── Markdown no bubble ──────────────────────────────────── */
.ai-msg-bubble p { margin: 0 0 0.5em; }
.ai-msg-bubble p:last-child { margin-bottom: 0; }
.ai-msg-bubble code {
  background: rgba(99,102,241,0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace, monospace;
  font-size: 0.85em;
}
.ai-msg-bubble pre {
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 12px 14px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.82em;
  margin: 8px 0;
}
.ai-msg-bubble pre code { background: none; padding: 0; color: inherit; }
.ai-msg-bubble ul, .ai-msg-bubble ol { padding-left: 1.4em; margin: 4px 0; }
.ai-msg-bubble li { margin: 2px 0; }
.ai-msg-bubble strong { font-weight: 600; }
.ai-msg-bubble table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 0.88em; }
.ai-msg-bubble th, .ai-msg-bubble td { border: 1px solid rgba(255,255,255,0.1); padding: 5px 10px; }
.ai-msg-bubble th { background: rgba(99,102,241,0.2); }
