/* ═══════════════════════════════════════════════════════════
   LIVE TERMINAL MONITOR + AI WATCHDOG TICKER
   v3.0 - Fixed position, real-time timer, file stats visible
   ═══════════════════════════════════════════════════════════ */

/* ─── Live Terminal Monitor ─── */
#live-terminal-monitor {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  margin: 0;
  overflow: hidden;
  background: rgba(8, 12, 25, 0.98);
  border-bottom: 2px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.7);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
  direction: ltr;
  text-align: left;
  transition: all 0.3s ease;
}

#live-terminal-monitor.ltm-collapsed .ltm-body {
  display: none;
}

.ltm-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.99), rgba(30, 58, 138, 0.7));
  border-bottom: 1px solid rgba(56, 189, 248, 0.2);
}

.ltm-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  animation: ltm-pulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes ltm-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px #22c55e; }
  50% { opacity: 0.3; box-shadow: 0 0 12px #22c55e; }
}

.ltm-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: rgba(56, 189, 248, 0.95);
  flex-shrink: 0;
}

.ltm-progress {
  font-size: 0.78rem;
  color: rgba(148, 163, 184, 0.9);
  margin-right: auto;
  font-weight: 500;
}

.ltm-eta {
  font-size: 0.82rem;
  color: rgba(251, 191, 36, 0.95);
  flex-shrink: 0;
  font-weight: 600;
  min-width: 60px;
  text-align: right;
}

.ltm-toggle {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: rgba(148, 163, 184, 0.8);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.ltm-toggle:hover {
  background: rgba(56, 189, 248, 0.2);
  color: #fff;
}

.ltm-body {
  padding: 10px 16px;
  max-height: 280px;
  overflow-y: auto;
}

.ltm-action-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(56, 189, 248, 0.1);
}

.ltm-action-icon {
  font-size: 1rem;
}

.ltm-action-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(34, 197, 94, 0.95);
}

.ltm-action-path {
  font-size: 0.72rem;
  color: rgba(251, 191, 36, 0.85);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 400px;
  direction: ltr;
  background: rgba(251, 191, 36, 0.05);
  padding: 2px 6px;
  border-radius: 3px;
}

.ltm-code-view {
  background: rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 8px;
  max-height: 120px;
  overflow-y: auto;
  border: 1px solid rgba(56, 189, 248, 0.1);
}

.ltm-code-view pre {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.5;
  color: rgba(226, 232, 240, 0.9);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ─── File Stats ─── */
.ltm-file-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(56, 189, 248, 0.08);
}

.ltm-file-stats-title {
  width: 100%;
  font-size: 0.72rem;
  color: rgba(148, 163, 184, 0.8);
  margin-bottom: 4px;
  font-weight: 600;
}

.ltm-file-entry {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(30, 41, 59, 0.8);
  border-radius: 5px;
  padding: 3px 8px;
  border: 1px solid rgba(56, 189, 248, 0.12);
}

.ltm-file-name {
  font-size: 0.68rem;
  color: rgba(226, 232, 240, 0.85);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ltm-file-badge {
  font-size: 0.64rem;
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}

.ltm-file-badge.ltm-read {
  color: rgba(56, 189, 248, 0.95);
  background: rgba(56, 189, 248, 0.08);
}

.ltm-file-badge.ltm-write {
  color: rgba(251, 191, 36, 0.95);
  background: rgba(251, 191, 36, 0.08);
}

/* ─── Watchdog News Ticker ─── */
.wd-ticker, #wd-ticker {
  position: fixed;
  bottom: 80px;
  left: 10px;
  right: 10px;
  z-index: 10001;
  transform: translateY(100%);
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease;
  opacity: 0;
  pointer-events: none;
  border-radius: 10px;
  overflow: hidden;
}

.wd-ticker.wd-ticker-visible, #wd-ticker.wd-ticker-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.wd-ticker.wd-ticker-hidden, #wd-ticker.wd-ticker-hidden {
  transform: translateY(100%);
  opacity: 0;
}

.wd-ticker-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.98), rgba(100, 60, 10, 0.95));
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.wd-ticker-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.wd-ticker-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(251, 191, 36, 0.95);
  white-space: nowrap;
  flex-shrink: 0;
}

.wd-ticker-text {
  font-size: 0.8rem;
  color: rgba(226, 232, 240, 0.9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  direction: rtl;
  text-align: right;
}

.wd-ticker-meta {
  font-size: 0.72rem;
  color: rgba(148, 163, 184, 0.7);
  white-space: nowrap;
  flex-shrink: 0;
  direction: ltr;
}

/* ─── Mobile Responsive ─── */
@media (max-width: 768px) {
  #live-terminal-monitor {
    font-size: 0.9em;
  }
  .ltm-header {
    padding: 8px 10px;
    gap: 6px;
  }
  .ltm-body {
    padding: 8px 10px;
    max-height: 200px;
  }
  .ltm-code-view {
    max-height: 80px;
  }
  .ltm-action-path {
    max-width: 180px;
  }
  .wd-ticker-inner {
    padding: 10px 12px;
    gap: 6px;
  }
}

/* ─── Watchdog Response Ticker (Agent's reply - blue/green theme) ─── */
.wd-response-ticker, #wd-response-ticker {
  position: fixed;
  bottom: 140px;
  left: 10px;
  right: 10px;
  z-index: 10002;
  transform: translateY(100%);
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.5s ease;
  opacity: 0;
  pointer-events: none;
  border-radius: 10px;
  overflow: hidden;
}

.wd-response-ticker.wd-response-visible, #wd-response-ticker.wd-response-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.wd-response-ticker.wd-response-hidden, #wd-response-ticker.wd-response-hidden {
  transform: translateY(100%);
  opacity: 0;
}

.wd-response-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.98), rgba(6, 78, 59, 0.95));
  border: 1px solid rgba(34, 197, 94, 0.5);
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 12px rgba(34, 197, 94, 0.15);
}

.wd-response-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.wd-response-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(34, 197, 94, 0.95);
  white-space: nowrap;
  flex-shrink: 0;
}

.wd-response-text {
  font-size: 0.8rem;
  color: rgba(226, 232, 240, 0.9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  direction: rtl;
  text-align: right;
}


/* ─── Session Report Download Button ─── */
.session-report-btn, #session-report-btn {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(37, 99, 235, 0.9));
  color: #fff;
  border: 1px solid rgba(96, 165, 250, 0.5);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  margin-right: 8px;
  white-space: nowrap;
}
.session-report-btn:hover {
  background: linear-gradient(135deg, rgba(96, 165, 250, 1), rgba(59, 130, 246, 1));
  transform: scale(1.05);
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.4);
}


/* ═══════════════════════════════════════════════════════════
   MOBILE RESPONSIVE - Live Terminal + Watchdog + Report Button
   For screens <= 480px (phones)
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* ─── Live Terminal Monitor ─── */
  #live-terminal-monitor {
    font-size: 0.78em;
    border-bottom-width: 1px;
  }
  .ltm-header {
    padding: 6px 8px;
    gap: 4px;
    flex-wrap: wrap;
  }
  .ltm-title {
    font-size: 0.85em;
  }
  .ltm-eta {
    font-size: 0.8em;
  }
  .ltm-progress {
    font-size: 0.75em;
  }
  .ltm-body {
    padding: 6px 8px;
    max-height: 150px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ltm-code-view {
    max-height: 100px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 0.75em;
  }
  .ltm-code-view pre {
    white-space: pre-wrap;
    word-break: break-all;
  }
  .ltm-action-bar {
    flex-wrap: wrap;
    gap: 4px;
  }
  .ltm-action-path {
    max-width: 140px;
    font-size: 0.7em;
  }
  .ltm-file-stats {
    font-size: 0.75em;
  }
  .ltm-file-stats-title {
    font-size: 0.8em;
  }
  .ltm-file-entry {
    padding: 2px 0;
  }
  .ltm-file-name {
    max-width: 100px;
  }
  .ltm-file-badge {
    font-size: 0.7em;
    padding: 1px 4px;
  }
  .ltm-toggle {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }

  /* ─── Watchdog Nudge Ticker (Gold) ─── */
  .wd-ticker, #wd-ticker {
    bottom: 80px !important;
    left: 5px !important;
    right: 5px !important;
    border-radius: 8px;
  }
  .wd-ticker-inner {
    padding: 8px 10px;
    gap: 4px;
    font-size: 0.8em;
  }
  .wd-ticker-inner .wd-icon {
    font-size: 1.2em;
  }
  .wd-ticker-inner .wd-text {
    font-size: 0.78em;
    line-height: 1.3;
  }

  /* ─── Watchdog Response Ticker (Green/Blue) ─── */
  .wd-response-ticker, #wd-response-ticker {
    bottom: 80px !important;
    left: 5px !important;
    right: 5px !important;
    border-radius: 8px;
  }
  .wd-response-inner {
    padding: 8px 10px;
    gap: 4px;
    font-size: 0.8em;
  }
  .wd-response-inner .wd-icon {
    font-size: 1.2em;
  }
  .wd-response-inner .wd-text {
    font-size: 0.78em;
    line-height: 1.3;
  }

  /* ─── Session Report Download Button ─── */
  .session-report-btn, #session-report-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
    margin-right: 4px;
    min-height: 36px;
    min-width: 36px;
  }
}

/* ═══════════════════════════════════════════════════════════
   SMALL TABLETS (481px - 768px)
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 481px) and (max-width: 768px) {
  #live-terminal-monitor {
    font-size: 0.85em;
  }
  .ltm-body {
    max-height: 180px;
    overflow-y: auto;
  }
  .ltm-code-view {
    max-height: 100px;
    overflow-y: auto;
  }
  .ltm-code-view pre {
    white-space: pre-wrap;
    word-break: break-all;
  }
  .wd-ticker, #wd-ticker,
  .wd-response-ticker, #wd-response-ticker {
    left: 8px !important;
    right: 8px !important;
    bottom: 100px !important;
  }
  .session-report-btn, #session-report-btn {
    padding: 7px 14px;
    font-size: 0.78rem;
    min-height: 34px;
  }
}

/* ROSH_WD_INTERNAL_ONLY (2026-09-08): watchdog banners are agent-internal per owner directive; never render to users */
#wd-ticker, .wd-ticker, #wd-response-ticker, .wd-response-ticker { display: none !important; visibility: hidden !important; opacity: 0 !important; pointer-events: none !important; }
