/* ─── AI SCRAPER PAGE ─── */

.ai-main {
  padding-top: 4.5rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 2rem;
}

@media (min-width: 1024px) {
  .ai-main {
    margin-left: 240px;
  }
}

.terminal-wrapper {
  width: 100%;
  max-width: 860px;
  margin: 1.5rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 6rem);
}

/* ─── TOP BAR ─── */
.terminal-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #1a1a1a;
  border: 1px solid #2d2d2d;
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  padding: 0.6rem 1rem;
  flex-shrink: 0;
}

.terminal-dots {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.dot-red    { background: #ff5f57; }
.dot-yellow { background: #febc2e; }
.dot-green  { background: #28c840; }

.terminal-title {
  flex: 1;
  text-align: center;
  font-family: 'Fira Code', monospace;
  font-size: 0.75rem;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.terminal-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.term-btn {
  background: none;
  border: 1px solid #2d2d2d;
  border-radius: 6px;
  color: #6b7280;
  font-size: 0.7rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  font-family: 'Fira Code', monospace;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s;
}
.term-btn:hover {
  background: #2d2d2d;
  color: #ef4444;
  border-color: #ef4444;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transition: background 0.3s;
}
.status-dot.online  { background: #10b981; box-shadow: 0 0 6px #10b98166; animation: pulse-green 2s infinite; }
.status-dot.loading { background: #f59e0b; box-shadow: 0 0 6px #f59e0b66; animation: pulse-yellow 0.8s infinite; }
.status-dot.error   { background: #ef4444; }

@keyframes pulse-green  { 0%,100% { opacity:1; } 50% { opacity:0.5; } }
@keyframes pulse-yellow { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

.status-text {
  font-family: 'Fira Code', monospace;
  font-size: 0.7rem;
  color: #6b7280;
}

/* ─── BODY ─── */
.terminal-body {
  background: #0d0d0d;
  border: 1px solid #2d2d2d;
  border-bottom: none;
  padding: 1.25rem 1.25rem 0.5rem;
  flex: 1;
  overflow-y: auto;
  font-family: 'Fira Code', 'Fira Mono', Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  scroll-behavior: smooth;
}

.terminal-body::-webkit-scrollbar { width: 6px; }
.terminal-body::-webkit-scrollbar-track { background: transparent; }
.terminal-body::-webkit-scrollbar-thumb { background: #2d2d2d; border-radius: 3px; }
.terminal-body::-webkit-scrollbar-thumb:hover { background: #3d3d3d; }

/* ─── LINES ─── */
.term-line {
  margin-bottom: 0.75rem;
}
.term-divider {
  border: none;
  border-top: 1px dashed #1e1e1e;
  margin: 0.75rem 0 1rem;
}

.term-prompt {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 0.5rem;
  vertical-align: middle;
  background: #1e1e1e;
  color: #6b7280;
  border: 1px solid #2d2d2d;
}

.system-line .term-prompt { color: #6b7280; }
.system-line .term-text { color: #4b5563; font-size: 0.8rem; }
.system-line.dim .term-text { color: #374151; }

.user-prompt {
  background: rgba(99,102,241,0.1) !important;
  color: #818cf8 !important;
  border-color: rgba(99,102,241,0.2) !important;
}

.ai-prompt {
  background: rgba(16,185,129,0.1) !important;
  color: #10b981 !important;
  border-color: rgba(16,185,129,0.2) !important;
}

.error-prompt {
  background: rgba(239,68,68,0.1) !important;
  color: #ef4444 !important;
  border-color: rgba(239,68,68,0.2) !important;
}
.error-text { color: #ef4444; font-size: 0.85rem; }

kbd {
  background: #1e1e1e;
  border: 1px solid #2d2d2d;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'Fira Code', monospace;
  font-size: 0.7rem;
  color: #9ca3af;
}

/* ─── USER MESSAGE ─── */
.user-line { padding: 0.5rem 0; }
.user-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}
.user-text {
  color: #e2e8f0;
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  padding-left: 0.25rem;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(99,102,241,0.05);
  border-left: 2px solid rgba(99,102,241,0.3);
  padding: 0.5rem 0.75rem;
  border-radius: 0 6px 6px 0;
}

/* ─── AI MESSAGE ─── */
.ai-line { padding: 0.5rem 0; }
.ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.ai-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.msg-time {
  font-size: 0.68rem;
  color: #374151;
  font-family: 'Fira Code', monospace;
}

.ai-content {
  color: #d1d5db;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  line-height: 1.75;
  word-break: break-word;
}

/* ─── MARKDOWN STYLES ─── */
.ai-content .md-p { margin: 0.5rem 0; }
.ai-content .md-h1 { color: #f3f4f6; font-size: 1.1rem; font-weight: 700; margin: 1rem 0 0.5rem; border-bottom: 1px solid #2d2d2d; padding-bottom: 0.25rem; }
.ai-content .md-h2 { color: #f3f4f6; font-size: 1rem; font-weight: 600; margin: 0.875rem 0 0.4rem; }
.ai-content .md-h3 { color: #e5e7eb; font-size: 0.9rem; font-weight: 600; margin: 0.75rem 0 0.35rem; }
.ai-content .md-ul { margin: 0.35rem 0 0.35rem 1.25rem; padding: 0; list-style: none; }
.ai-content .md-li { position: relative; padding-left: 1rem; margin-bottom: 0.25rem; color: #d1d5db; }
.ai-content .md-li::before { content: '›'; position: absolute; left: 0; color: #10b981; font-weight: 700; }
.ai-content strong { color: #f9fafb; font-weight: 600; }
.ai-content em { color: #a5b4fc; font-style: italic; }

.ai-content .inline-code {
  background: #1e1e1e;
  border: 1px solid #2d2d2d;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Fira Code', monospace;
  font-size: 0.8rem;
  color: #f59e0b;
}

/* ─── CODE BLOCK ─── */
.code-block {
  margin: 0.75rem 0;
  border-radius: 8px;
  border: 1px solid #2d2d2d;
  overflow: hidden;
  background: #111;
}
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1a1a1a;
  border-bottom: 1px solid #2d2d2d;
  padding: 0.4rem 0.75rem;
}
.code-lang {
  font-family: 'Fira Code', monospace;
  font-size: 0.68rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.copy-btn {
  background: none;
  border: 1px solid #2d2d2d;
  border-radius: 5px;
  color: #6b7280;
  font-size: 0.68rem;
  font-family: 'Fira Code', monospace;
  padding: 2px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s;
}
.copy-btn:hover {
  background: #2d2d2d;
  color: #e2e8f0;
  border-color: #4b5563;
}
.code-block pre {
  margin: 0 !important;
  padding: 1rem !important;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
}
.code-block pre::-webkit-scrollbar { height: 5px; }
.code-block pre::-webkit-scrollbar-track { background: transparent; }
.code-block pre::-webkit-scrollbar-thumb { background: #2d2d2d; border-radius: 3px; }

/* ─── THINKING DOTS ─── */
.thinking-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0;
}
.thinking-dots {
  display: flex;
  gap: 5px;
  align-items: center;
}
.thinking-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  opacity: 0.3;
  animation: thinking-bounce 1.2s infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.3; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ─── INPUT AREA ─── */
.terminal-input-area {
  background: #111;
  border: 1px solid #2d2d2d;
  border-radius: 0 0 12px 12px;
  padding: 0.6rem 1rem 0.55rem;
  flex-shrink: 0;
}

.input-prompt-bar {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.input-prompt {
  font-family: 'Fira Code', monospace;
  font-size: 0.72rem;
  color: #10b981;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.input-body-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  width: 100%;
}

.term-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: #e2e8f0;
  font-family: 'Fira Code', monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: none;
  outline: none;
  max-height: 160px;
  overflow-y: auto;
  overflow-x: hidden;
  caret-color: #10b981;
  padding: 2px 0;
  min-height: 22px;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  width: 100%;
  box-sizing: border-box;
}
.term-input::placeholder { color: #374151; }
.term-input:disabled { opacity: 0.5; cursor: not-allowed; }

.send-btn {
  background: #10b981;
  border: none;
  border-radius: 8px;
  color: #fff;
  width: 34px;
  height: 34px;
  min-width: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}
.send-btn:hover:not(:disabled) { background: #059669; transform: scale(1.05); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.send-btn.loading {
  background: #1e1e1e;
  animation: pulse-yellow 0.8s infinite;
}

.input-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 5px;
}
.char-count {
  font-family: 'Fira Code', monospace;
  font-size: 0.65rem;
  color: #374151;
}
.input-hint {
  font-family: 'Fira Code', monospace;
  font-size: 0.65rem;
  color: #374151;
}

/* ─── CODE BLOCK ACTIONS ─── */
.cb-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.run-btn {
  background: rgba(16,185,129,0.1);
  border: 1px solid rgba(16,185,129,0.3);
  border-radius: 5px;
  color: #10b981;
  font-size: 0.68rem;
  font-family: 'Fira Code', monospace;
  padding: 2px 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s;
}
.run-btn:hover { background: rgba(16,185,129,0.2); border-color: #10b981; }
.run-btn.active {
  background: rgba(245,158,11,0.1);
  border-color: rgba(245,158,11,0.4);
  color: #f59e0b;
}

/* ─── LIVE PREVIEW PANEL ─── */
.preview-panel {
  border-top: 1px solid #2d2d2d;
  animation: slide-in 0.2s ease-out;
}

.preview-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.75rem;
  background: #0d1a14;
  border-bottom: 1px solid rgba(16,185,129,0.15);
}

.preview-label {
  font-family: 'Fira Code', monospace;
  font-size: 0.7rem;
  color: #10b981;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.preview-action-btn {
  background: none;
  border: 1px solid #2d2d2d;
  border-radius: 5px;
  color: #6b7280;
  font-size: 0.68rem;
  font-family: 'Fira Code', monospace;
  padding: 2px 7px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s;
}
.preview-action-btn:hover { background: #1e1e1e; color: #d1d5db; }

.preview-iframe {
  width: 100%;
  min-height: 260px;
  border: none;
  background: #fff;
  display: block;
}

/* ─── FULLSCREEN PREVIEW MODAL ─── */
.fullscreen-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #000;
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.2s ease-out;
}

.fs-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: #111;
  border-bottom: 1px solid #2d2d2d;
  flex-shrink: 0;
}

.fs-close-btn {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: 6px;
  color: #ef4444;
  font-size: 0.75rem;
  font-family: 'Fira Code', monospace;
  padding: 4px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s;
}
.fs-close-btn:hover { background: rgba(239,68,68,0.2); }

.fs-iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #fff;
}

/* ─── ICON BTN ─── */
.icon-btn {
  background: none;
  border: 1px solid #2d2d2d;
  border-radius: 5px;
  color: #4b5563;
  padding: 3px 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}
.icon-btn:hover { background: #1e1e1e; color: #9ca3af; border-color: #4b5563; }

/* ─── TOAST ─── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  background: #1a1a1a;
  border: 1px solid #2d2d2d;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-family: 'Fira Code', monospace;
  font-size: 0.75rem;
  color: #9ca3af;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.25s ease;
  max-width: 300px;
}
.toast.toast-show { opacity: 1; transform: translateY(0); }
.toast.toast-success { border-color: rgba(16,185,129,0.4); color: #10b981; }
.toast.toast-error   { border-color: rgba(239,68,68,0.4); color: #ef4444; }

/* ─── ANIMATIONS ─── */
@keyframes slide-in {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}
.animate-slide-in { animation: slide-in 0.25s ease-out forwards; }

/* ─── SESSION BADGE ─── */
.session-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.2);
  border-radius: 20px;
  padding: 0.2rem 0.6rem;
  font-family: 'Fira Code', monospace;
  font-size: 0.65rem;
  color: #10b981;
  flex-shrink: 0;
}
.session-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  animation: pulse-green 2s infinite;
  flex-shrink: 0;
}

/* ─── NEW CHAT BUTTON ─── */
.new-chat-btn:hover {
  color: #10b981 !important;
  border-color: #10b981 !important;
  background: rgba(16,185,129,0.08) !important;
}

/* ─── MODE TABS ─── */
.mode-tabs {
  display: flex;
  gap: 0;
  background: #161616;
  border-left: 1px solid #2d2d2d;
  border-right: 1px solid #2d2d2d;
  border-bottom: 1px solid #2d2d2d;
  flex-shrink: 0;
}
.mode-tab {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #4b5563;
  font-family: 'Fira Code', monospace;
  font-size: 0.72rem;
  cursor: pointer;
  transition: all 0.15s;
}
.mode-tab:hover {
  color: #9ca3af;
  background: rgba(255,255,255,0.03);
}
.mode-tab.active {
  color: #6366f1;
  border-bottom-color: #6366f1;
  background: rgba(99,102,241,0.06);
}
#tabChat.active {
  color: #10b981;
  border-bottom-color: #10b981;
  background: rgba(16,185,129,0.06);
}

/* ─── URL / PARSER INPUT ─── */
.url-input {
  background: none !important;
  border: none !important;
  outline: none !important;
  font-family: 'Fira Code', monospace;
  font-size: 0.82rem;
  color: #d1d5db;
  flex: 1;
  padding: 0.5rem 0;
  resize: none;
  caret-color: #6366f1;
}
.url-input::placeholder { color: #374151; }
.url-input:disabled { opacity: 0.5; }

.parser-send-btn {
  background: linear-gradient(135deg, #6366f1, #818cf8);
  border: none;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  color: white;
}
.parser-send-btn:hover { background: linear-gradient(135deg, #4f46e5, #6366f1); transform: scale(1.05); }
.parser-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ─── MOBILE ─── */
@media (max-width: 640px) {
  .terminal-wrapper { margin: 1rem auto; padding: 0 0.5rem; height: calc(100vh - 5.5rem); }
  .terminal-title   { display: none; }
  .input-hint       { display: none; }
  .term-btn span    { display: none; }
  .session-badge    { display: none; }
  .mode-tab         { font-size: 0.65rem; padding: 0.45rem 0.7rem; }
}
