/**
 * RobotDog PoC - Monitor page styles (monitor.html)
 */

/* ------------------------------------------------------------------ */
/* Reset & base                                                        */
/* ------------------------------------------------------------------ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ------------------------------------------------------------------ */
/* Header                                                              */
/* ------------------------------------------------------------------ */
header {
  background: #16213e;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #0f3460;
  flex-shrink: 0;
}

header h1 {
  font-size: 18px;
  color: #00d2ff;
}

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

/* ------------------------------------------------------------------ */
/* Buttons                                                             */
/* ------------------------------------------------------------------ */
.btn {
  background: #0f3460;
  color: #e0e0e0;
  border: 1px solid #00d2ff;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.btn:hover {
  background: #00d2ff;
  color: #1a1a2e;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: #0f3460;
  color: #e0e0e0;
}

/* ------------------------------------------------------------------ */
/* Chat area                                                           */
/* ------------------------------------------------------------------ */
#chat {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}

#chat::-webkit-scrollbar {
  width: 6px;
}

#chat::-webkit-scrollbar-track {
  background: transparent;
}

#chat::-webkit-scrollbar-thumb {
  background: #0f3460;
  border-radius: 3px;
}

/* Message bubbles */
.msg {
  padding: 10px 14px;
  border-radius: 8px;
  max-width: 85%;
  line-height: 1.5;
  font-size: 14px;
  word-break: break-word;
  animation: fadeIn 0.2s ease;
}

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

.msg.user {
  align-self: flex-end;
  background: #0f3460;
  color: #e0e0e0;
  border-bottom-right-radius: 2px;
}

.msg.assistant {
  align-self: flex-start;
  background: #16213e;
  border: 1px solid #0f3460;
  border-bottom-left-radius: 2px;
}

.msg.thinking {
  align-self: flex-start;
  background: #1a1a2e;
  border: 1px solid #333;
  color: #888;
  font-style: italic;
  font-size: 13px;
  border-bottom-left-radius: 2px;
}

.msg.tool {
  align-self: flex-start;
  background: #0d1117;
  border: 1px solid #21262d;
  color: #7ee787;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  border-bottom-left-radius: 2px;
}

.msg.tool.error {
  color: #ff6b6b;
  border-color: #ff6b6b40;
}

.msg.toolResult {
  align-self: flex-end;
  background: #0d1117;
  border: 1px solid #21262d;
  color: #7ee787;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  border-bottom-right-radius: 2px;
}

.msg.toolResult.error {
  color: #ff6b6b;
  border-color: #ff6b6b40;
}

.msg.system {
  align-self: center;
  background: none;
  color: #666;
  font-size: 12px;
  border: none;
}

.msg.error {
  align-self: center;
  background: none;
  color: #ff6b6b;
  font-size: 13px;
}

/* ------------------------------------------------------------------ */
/* Status bar                                                          */
/* ------------------------------------------------------------------ */
#status-bar {
  background: #0d1117;
  padding: 6px 16px;
  font-size: 12px;
  color: #888;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  border-top: 1px solid #0f3460;
  flex-shrink: 0;
}

#status-bar .status-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.connected {
  background: #7ee787;
}

.dot.disconnected {
  background: #ff6b6b;
}

.dot.error {
  background: #ff6b6b;
}

.dot.processing {
  background: #f0c040;
  animation: blink 1s infinite;
}

/* ------------------------------------------------------------------ */
/* LLM server status indicator                                         */
/* ------------------------------------------------------------------ */
.llm-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
}

.llm-status.connected {
  color: #7ee787;
}

.llm-status.disconnected {
  color: #ff6b6b;
}

.llm-model {
  color: #00d2ff;
  font-size: 12px;
}

.llm-base-url {
  color: #ff6b6b;
  font-size: 11px;
  font-family: monospace;
}

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

/* ------------------------------------------------------------------ */
/* Markdown rendering (inside .msg blocks)                              */
/* ------------------------------------------------------------------ */
.msg.markdown-body > :first-child {
  margin-top: 0;
}
.msg.markdown-body > :last-child {
  margin-bottom: 0;
}

.msg h1, .msg h2, .msg h3, .msg h4, .msg h5, .msg h6 {
  margin: 0.5em 0 0.25em;
  font-size: 1em;
  font-weight: 600;
  color: #e0e0e0;
}
.msg h1 { font-size: 1.1em; }
.msg h2 { font-size: 1.05em; }

.msg p {
  margin: 0.35em 0;
  line-height: 1.6;
}

.msg code {
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.85em;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  color: #f0883e;
}

.msg pre {
  background: #0d1117;
  border: 1px solid #21262d;
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  margin: 0.5em 0;
}

.msg pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 0.85em;
  color: #e0e0e0;
}

.msg ul, .msg ol {
  margin: 0.35em 0;
  padding-left: 1.5em;
}

.msg li {
  margin: 0.2em 0;
  line-height: 1.6;
}

.msg blockquote {
  border-left: 3px solid #00d2ff;
  margin: 0.5em 0;
  padding: 4px 12px;
  color: #888;
  background: rgba(0, 210, 255, 0.05);
  border-radius: 0 4px 4px 0;
}

.msg table {
  border-collapse: collapse;
  margin: 0.5em 0;
  width: 100%;
  font-size: 0.9em;
}

.msg th, .msg td {
  border: 1px solid #21262d;
  padding: 6px 10px;
  text-align: left;
}

.msg th {
  background: #0d1117;
  font-weight: 600;
}

.msg hr {
  border: none;
  border-top: 1px solid #21262d;
  margin: 0.75em 0;
}

.msg a {
  color: #00d2ff;
  text-decoration: none;
}
.msg a:hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------------ */
/* Collapsible session panel                                           */
/* ------------------------------------------------------------------ */
.session-panel {
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  flex-shrink: 0;
}

.session-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 20px;
  font-size: 13px;
  color: #00d2ff;
  user-select: none;
}

.session-toggle-btn {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}

.session-toggle-btn:hover {
  color: #00d2ff;
  background: #0f3460;
}

.session-panel-body {
  max-height: 240px;
  overflow-y: auto;
  padding: 0;
  transition: max-height 0.25s ease;
}

.session-panel.collapsed .session-panel-body {
  max-height: 0;
  overflow: hidden;
}

/* ------------------------------------------------------------------ */
/* Session list                                                        */
/* ------------------------------------------------------------------ */
.session-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 18px;
  border-bottom: 1px solid #0f346088;
  cursor: pointer;
  transition: background 0.12s;
  font-size: 13px;
}

.session-list-item:last-child {
  border-bottom: none;
}

.session-list-item:hover {
  background: #1a2744;
}

.session-list-item.active {
  background: #0f3460;
}

.session-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 90px;
  flex-shrink: 0;
}

.session-id-badge {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  color: #58a6ff;
  font-weight: 600;
}

.session-list-item.active .session-id-badge {
  color: #79c0ff;
}

.session-time {
  color: #6e7681;
  font-size: 10px;
}

.session-preview {
  flex: 1;
  color: #c9d1d9;
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.session-list-item.active .session-preview {
  color: #e6edf3;
  font-weight: 500;
}

.session-right {
  color: #6e7681;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  min-width: 50px;
  text-align: right;
  flex-shrink: 0;
}

.session-list-item.active .session-right {
  color: #8b949e;
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */
@media (max-width: 600px) {
  header {
    padding: 10px 12px;
  }

  header h1 {
    font-size: 15px;
  }

  .msg {
    max-width: 95%;
  }

  #chat {
    padding: 10px;
  }

  #status-bar {
    font-size: 11px;
    gap: 8px;
  }
}
