/* ═══════════════════════════════════════════════════
   J.A.R.V.I.S — chatbot.css
   Dark futuristic HUD interface
═══════════════════════════════════════════════════ */

:root {
  --bg:         linear-gradient(135deg, #1a0a3a 0%, #2d1b5e 50%, #1a2a5a 100%);
  --panel:      rgba(20, 30, 60, 0.8);
  --border:     rgba(100, 150, 255, 0.3);
  --border2:    rgba(100, 150, 255, 0.15);
  --blue:       #00aaff;
  --cyan:       #00ffcc;
  --red:        #ff3344;
  --text:       #b8d8f0;
  --muted:      #7a9abd;
  --dim:        #0f1a35;
  --font-hud:   'Orbitron', monospace;
  --font-body:  'Rajdhani', sans-serif;
}

/* ═══════════════════════════════════════════════════
   WRAPPER — scopes all styles away from Bootstrap
═══════════════════════════════════════════════════ */
.jarvis-ui {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 32px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(100, 150, 255, 0.15);
}

/* ═══════════════════════════════════════════════════
   HEADER
═══════════════════════════════════════════════════ */
.j-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 36px;
  background: rgba(12, 18, 48, 0.95);
  border-bottom: 1px solid rgba(100, 150, 255, 0.2);
  backdrop-filter: blur(10px);
}

.logo { display: flex; align-items: center; gap: 16px; }

.logo-arc {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.arc-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--blue);
  border-top-color: transparent;
  animation: spin 4s linear infinite;
  box-shadow: 0 0 10px rgba(0,170,255,0.4);
}

.arc-ring::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1px solid rgba(0,255,204,0.35);
  border-bottom-color: transparent;
  animation: spin 2.5s linear infinite reverse;
}

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

.arc-core {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 14px var(--blue), 0 0 28px rgba(0,170,255,0.4);
  animation: core-pulse 2s ease-in-out infinite;
}

@keyframes core-pulse {
  0%,100% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
  50%      { transform: translate(-50%,-50%) scale(0.65); opacity: 0.45; }
}

.logo-title {
  font-family: var(--font-hud);
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--blue);
  text-shadow: 0 0 18px var(--blue), 0 0 36px rgba(0,170,255,0.25);
}

.logo-sub {
  font-family: var(--font-hud);
  font-size: 0.42rem;
  letter-spacing: 3px;
  color: var(--muted);
  margin-top: 4px;
  opacity: 0.8;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 28px;
}

.sys-stat {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: blink 1.8s ease-in-out infinite;
}

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.2} }

.stat-label {
  font-family: var(--font-hud);
  font-size: 0.55rem;
  letter-spacing: 2px;
  color: var(--muted);
}

/* ═══════════════════════════════════════════════════
   TABS
═══════════════════════════════════════════════════ */
.j-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(12, 18, 48, 0.85);
  border-bottom: 1px solid rgba(100, 150, 255, 0.18);
  padding: 0 36px 0 28px;
  backdrop-filter: blur(6px);
}

.tab-left { display: flex; align-items: center; }
.tab-right { display: flex; align-items: center; gap: 16px; }

.tab {
  padding: 12px 22px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-family: var(--font-hud);
  font-size: 0.58rem;
  letter-spacing: 3px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, text-shadow 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab .tab-icon { font-size: 0.75rem; }
.tab:hover { color: var(--blue); }

.tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  text-shadow: 0 0 10px var(--blue);
}

.msg-counter {
  font-family: var(--font-hud);
  font-size: 0.48rem;
  letter-spacing: 2px;
  color: rgba(100, 150, 255, 0.4);
}

.clear-btn {
  padding: 5px 14px;
  background: transparent;
  border: 1px solid rgba(100, 150, 255, 0.2);
  color: var(--muted);
  font-family: var(--font-hud);
  font-size: 0.5rem;
  letter-spacing: 2px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.2s;
}

.clear-btn:hover {
  border-color: var(--red);
  color: var(--red);
  box-shadow: 0 0 8px rgba(255, 51, 68, 0.2);
}

/* ═══════════════════════════════════════════════════
   MAIN CONTAINER
═══════════════════════════════════════════════════ */
.j-main {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  background: rgba(12, 18, 48, 0.7);
  backdrop-filter: blur(8px);
}

.panel { display: none; flex-direction: column; }
.panel.active { display: flex; }

/* ═══════════════════════════════════════════════════
   CHAT PANEL
═══════════════════════════════════════════════════ */
.messages {
  flex: 1;
  min-height: 380px;
  max-height: 560px;
  overflow-y: auto;
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 150, 255, 0.25) transparent;
}

.messages::-webkit-scrollbar { width: 3px; }
.messages::-webkit-scrollbar-track { background: transparent; }
.messages::-webkit-scrollbar-thumb {
  background: rgba(100, 150, 255, 0.25);
  border-radius: 2px;
}

.message {
  display: flex;
  gap: 14px;
  animation: rise 0.28s ease forwards;
  opacity: 0;
}

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

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

.msg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-hud);
  font-size: 0.48rem;
  font-weight: 700;
  letter-spacing: 1px;
  flex-shrink: 0;
  margin-top: 3px;
}

.message.assistant .msg-avatar {
  background: rgba(0,170,255,0.08);
  border: 1px solid rgba(0,170,255,0.3);
  color: var(--blue);
  box-shadow: 0 0 10px rgba(0,170,255,0.12);
}

.message.user .msg-avatar {
  background: rgba(0,255,204,0.07);
  border: 1px solid rgba(0,255,204,0.22);
  color: var(--cyan);
}

.msg-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 720px;
}

/* label + timestamp on same row */
.msg-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.msg-label {
  font-family: var(--font-hud);
  font-size: 0.5rem;
  letter-spacing: 3px;
  color: var(--muted);
}

.message.user .msg-meta { flex-direction: row-reverse; }
.message.user .msg-label { color: rgba(0,255,204,0.45); }

.msg-time {
  font-family: var(--font-hud);
  font-size: 0.44rem;
  letter-spacing: 1px;
  color: rgba(100, 150, 255, 0.35);
}

.msg-bubble {
  padding: 13px 18px;
  line-height: 1.75;
  font-size: 0.97rem;
  font-weight: 400;
}

.message.assistant .msg-bubble {
  background: rgba(0,25,55,0.75);
  border: 1px solid rgba(0,170,255,0.14);
  border-left: 2px solid var(--blue);
  color: var(--text);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
}

.message.user .msg-bubble {
  background: rgba(0,35,25,0.75);
  border: 1px solid rgba(0,255,204,0.11);
  border-right: 2px solid var(--cyan);
  color: #90f0d8;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 10px 100%, 0 calc(100% - 10px));
}

/* Markdown inside bubbles */
.msg-bubble strong { color: #e0f4ff; font-weight: 600; }
.msg-bubble em { color: var(--cyan); font-style: normal; }
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  font-family: var(--font-hud);
  color: var(--blue);
  letter-spacing: 2px;
  margin: 10px 0 5px;
  font-size: 0.75rem;
}
.msg-bubble code {
  background: rgba(0,170,255,0.1);
  border: 1px solid rgba(0,170,255,0.2);
  color: var(--cyan);
  padding: 1px 6px;
  font-size: 0.85em;
  border-radius: 2px;
}
.msg-bubble pre {
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--border);
  padding: 12px 14px;
  margin: 8px 0;
  overflow-x: auto;
  font-size: 0.82em;
  border-left: 2px solid var(--blue);
}
.msg-bubble ul, .msg-bubble ol { padding-left: 18px; margin: 6px 0; }
.msg-bubble li { margin-bottom: 3px; }

/* Message action row (speak + copy) */
.msg-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.speak-btn, .copy-msg-btn {
  padding: 4px 13px;
  background: transparent;
  border: 1px solid rgba(0,170,255,0.22);
  color: var(--muted);
  font-family: var(--font-hud);
  font-size: 0.48rem;
  letter-spacing: 2px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.2s;
}

.speak-btn:hover, .copy-msg-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: 0 0 8px rgba(0,170,255,0.18);
}

.speak-btn:disabled, .copy-msg-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* Typing indicator */
.typing-dots {
  display: flex;
  gap: 5px;
  padding: 12px 18px;
  align-items: center;
}

.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 6px var(--blue);
  animation: dot-bounce 1.2s ease-in-out infinite;
}

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

@keyframes dot-bounce {
  0%,60%,100% { transform: translateY(0); opacity: 0.3; }
  30% { transform: translateY(-7px); opacity: 1; }
}

/* Chat footer */
.chat-footer {
  padding: 14px 32px 18px;
  background: rgba(10, 15, 40, 0.6);
  border-top: 1px solid rgba(100, 150, 255, 0.15);
  flex-shrink: 0;
}

.input-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: rgba(8, 14, 34, 0.9);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.97rem;
  font-weight: 400;
  outline: none;
  resize: none;
  min-height: 46px;
  max-height: 130px;
  transition: border-color 0.2s, box-shadow 0.2s;
  scrollbar-width: thin;
  line-height: 1.5;
}

.chat-input::placeholder { color: var(--muted); opacity: 0.7; }

.chat-input:focus {
  border-color: rgba(0,170,255,0.45);
  box-shadow: 0 0 0 1px rgba(0,170,255,0.1), 0 0 18px rgba(0,170,255,0.07);
}

.send-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  background: rgba(0,170,255,0.07);
  border: 1px solid var(--blue);
  color: var(--blue);
  font-family: var(--font-hud);
  font-size: 0.6rem;
  letter-spacing: 2px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
  text-shadow: 0 0 8px var(--blue);
  white-space: nowrap;
}

.send-btn:hover {
  background: rgba(0,170,255,0.14);
  box-shadow: 0 0 16px rgba(0,170,255,0.22);
}

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

.mic-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  background: rgba(0,255,204,0.06);
  border: 1px solid rgba(0,255,204,0.3);
  color: var(--cyan);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

.mic-btn:hover {
  background: rgba(0,255,204,0.14);
  box-shadow: 0 0 14px rgba(0,255,204,0.2);
}

.mic-btn.recording {
  background: rgba(255,51,68,0.12);
  border-color: var(--red);
  color: var(--red);
  box-shadow: 0 0 16px rgba(255,51,68,0.3);
  animation: mic-pulse 1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%,100% { box-shadow: 0 0 8px rgba(255,51,68,0.3); }
  50%      { box-shadow: 0 0 22px rgba(255,51,68,0.6); }
}

.input-hint {
  margin-top: 8px;
  font-family: var(--font-hud);
  font-size: 0.44rem;
  letter-spacing: 1.5px;
  color: rgba(100, 150, 255, 0.3);
  text-align: right;
}

/* ═══════════════════════════════════════════════════
   RESEARCH PANEL
═══════════════════════════════════════════════════ */
#research-panel {
  overflow-y: auto;
  padding: 32px 36px;
  gap: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 150, 255, 0.25) transparent;
  min-height: 520px;
}

.research-title {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 6px;
}

.r-icon {
  font-size: 1.5rem;
  color: var(--cyan);
  text-shadow: 0 0 14px var(--cyan);
  line-height: 1;
  margin-top: 2px;
}

.r-heading {
  font-family: var(--font-hud);
  font-size: 0.72rem;
  letter-spacing: 4px;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan);
  margin-bottom: 6px;
}

.r-sub {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.55;
}

.research-form {
  display: flex;
  gap: 10px;
}

.research-input {
  flex: 1;
  background: rgba(8, 14, 34, 0.9);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 13px 18px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.97rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.research-input::placeholder { color: var(--muted); opacity: 0.7; }

.research-input:focus {
  border-color: rgba(0,255,204,0.4);
  box-shadow: 0 0 0 1px rgba(0,255,204,0.08), 0 0 18px rgba(0,255,204,0.05);
}

.initiate-btn {
  padding: 13px 28px;
  background: rgba(0,255,204,0.06);
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-family: var(--font-hud);
  font-size: 0.6rem;
  letter-spacing: 2px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s;
  text-shadow: 0 0 8px var(--cyan);
  white-space: nowrap;
}

.initiate-btn:hover {
  background: rgba(0,255,204,0.12);
  box-shadow: 0 0 16px rgba(0,255,204,0.18);
}

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

/* Status + progress bar row */
.research-status-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 32px;
}

.research-status {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rs-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
  animation: blink 1s infinite;
  display: none;
  flex-shrink: 0;
}

.research-status.running .rs-dot { display: block; }

.rs-text {
  font-family: var(--font-hud);
  font-size: 0.55rem;
  letter-spacing: 2px;
  color: var(--muted);
  transition: color 0.3s;
}

.research-status.running .rs-text { color: var(--cyan); }

/* Progress bar */
.research-progress {
  height: 2px;
  background: rgba(100, 150, 255, 0.1);
  border-radius: 1px;
  overflow: hidden;
  display: none;
}

.research-progress.visible { display: block; }

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  border-radius: 1px;
  transition: width 0.6s ease;
  box-shadow: 0 0 8px var(--cyan);
}

/* Report box */
.report-container {
  background: rgba(10, 15, 40, 0.6);
  border: 1px solid rgba(100, 150, 255, 0.18);
  border-top: 2px solid var(--cyan);
  padding: 28px 32px;
  display: none;
  animation: rise 0.4s ease forwards;
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 0 100%);
  border-radius: 0 0 4px 4px;
}

.report-container.visible { display: block; }

.report-container h1 {
  font-family: var(--font-hud);
  font-size: 0.85rem;
  letter-spacing: 3px;
  color: var(--cyan);
  margin: 1.2em 0 0.5em;
  text-shadow: 0 0 10px var(--cyan);
}

.report-container h2 {
  font-family: var(--font-hud);
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: var(--blue);
  margin: 1.2em 0 0.4em;
}

.report-container h3 {
  font-size: 0.95rem;
  color: var(--text);
  font-weight: 600;
  margin: 0.8em 0 0.3em;
}

.report-container p {
  color: #7aaac8;
  line-height: 1.8;
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.report-container ul, .report-container ol {
  padding-left: 20px;
  color: #7aaac8;
  font-size: 0.9rem;
  line-height: 1.8;
  margin-bottom: 10px;
}

.report-container li { margin-bottom: 4px; }
.report-container a { color: var(--cyan); text-decoration: none; }
.report-container a:hover { text-decoration: underline; }
.report-container strong { color: var(--text); }
.report-container hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* Report action buttons */
.report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.action-btn {
  padding: 8px 18px;
  background: transparent;
  border: 1px solid var(--border2);
  color: var(--muted);
  font-family: var(--font-hud);
  font-size: 0.55rem;
  letter-spacing: 2px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.action-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  box-shadow: 0 0 8px rgba(0,170,255,0.15);
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .j-header { padding: 16px 20px; }
  .j-tabs { padding: 0 16px 0 10px; }
  .messages, #research-panel { padding: 18px 16px; }
  .chat-footer { padding: 12px 16px 16px; }
  .msg-body { max-width: 100%; }
  .tab-right { display: none; }
}
