/* Stripped-down mirror of local desktop chat UI. All actions via remote API only. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font-family: system-ui, -apple-system, sans-serif; }

:root {
  --bubble-user: #7aa2f7;
  --bubble-user-text: #1a1b26;
  --bubble-assistant: #363b54;
  --bubble-assistant-text: #c0caf5;
  --bubble-header-bg: rgba(0, 0, 0, 0.15);
}

body { background: #1a1b26; color: #c0caf5; }

/* ----- Login ----- */
#login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-box { max-width: 360px; width: 100%; padding: 2rem; background: #24283b; border-radius: 8px; border: 1px solid #363b54; }
.login-box h1 { margin: 0 0 0.5rem 0; font-size: 1.25rem; color: #c0caf5; }
.login-box p { margin: 0 0 1rem 0; color: #565f89; font-size: 0.9rem; }
.login-box input { width: 100%; padding: 0.5rem 0.75rem; margin-bottom: 1rem; border: 1px solid #363b54; border-radius: 4px; background: #1a1b26; color: #c0caf5; }
.login-box button { width: 100%; padding: 0.6rem; background: #7aa2f7; color: #1a1b26; border: none; border-radius: 4px; cursor: pointer; font-size: 1rem; font-weight: 600; }
.login-box button:hover { background: #89b4fa; }
.login-error { color: #f7768e; font-size: 0.9rem; margin-top: 0.5rem; }

.hidden { display: none !important; }

/* ----- App layout (mirror local: toolbar + content) ----- */
.remote-app { display: flex; flex-direction: column; height: 100vh; background: #1a1b26; }
.remote-toolbar {
  flex: 0 0 auto;
  padding: 8px 12px;
  background: #16161e;
  border-bottom: 1px solid #363b54;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.remote-toolbar h1 { margin: 0; font-size: 14px; font-weight: 600; color: #c0caf5; }
.remote-toolbar button {
  padding: 6px 12px;
  background: #414868;
  color: #c0caf5;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
.remote-toolbar button:hover { background: #565f89; }
.remote-toolbar button.primary { background: #7aa2f7; color: #1a1b26; }
.remote-toolbar button.primary:hover { background: #89b4fa; }

.remote-status-modal {
  padding: 8px 12px;
  background: #0f3460;
  color: #c0caf5;
  text-align: center;
  font-size: 13px;
  border-bottom: 1px solid #363b54;
}
.remote-status-modal p { margin: 0; }

.remote-body { display: flex; flex: 1; min-height: 0; }
.remote-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #16161e;
  border-right: 1px solid #363b54;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.remote-sidebar h2 { margin: 0; padding: 10px 12px; font-size: 12px; font-weight: 600; color: #565f89; border-bottom: 1px solid #363b54; }
.remote-chat-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.remote-chat-list li {
  padding: 8px 10px;
  margin-bottom: 2px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  word-break: break-all;
  color: #a9b1d6;
}
.remote-chat-list li:hover { background: #363b54; color: #c0caf5; }
.remote-chat-list li.active { background: #414868; color: #c0caf5; }
.remote-sidebar .btn-new-chat {
  margin: 8px;
  padding: 8px 12px;
  background: #7aa2f7;
  color: #1a1b26;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.remote-sidebar .btn-new-chat:hover { background: #89b4fa; }

.remote-main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #1a1b26; }
.remote-no-chat {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: #565f89;
  font-size: 13px;
}
.remote-chat-area { flex: 1; display: flex; flex-direction: column; min-height: 0; }

/* ----- Chat messages (same structure as local .chat-messages) ----- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.chat-messages-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: #565f89;
  font-size: 13px;
}
.chat-messages-empty .empty-msg { margin-bottom: 8px; }
.chat-messages-empty .empty-hint { font-size: 12px; color: #414868; }

.chat-message-wrapper {
  position: relative;
  max-width: 90%;
  margin-bottom: 4px;
}
.chat-message {
  max-width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-message-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  margin: -10px -12px 8px -12px;
  border-radius: 8px 8px 0 0;
  background: var(--bubble-header-bg, rgba(0, 0, 0, 0.15));
  min-height: 28px;
}
.chat-message-sender { font-size: 12px; font-weight: 600; flex-shrink: 0; }
.chat-message-timestamp { font-size: 11px; opacity: 0.9; flex-shrink: 0; }
.chat-message-body { margin: 0; padding: 0 2px; }

.chat-message.user {
  align-self: flex-end;
  background: var(--bubble-user, #7aa2f7);
  color: var(--bubble-user-text, #1a1b26);
}
.chat-message.user.remote { border: 2px solid #e0af68; }
.chat-message.user.local { border: 2px solid #9ece6a; }
.chat-message.assistant {
  align-self: flex-start;
  background: var(--bubble-assistant, #363b54);
  color: var(--bubble-assistant-text, #c0caf5);
}
.chat-message.error {
  align-self: flex-start;
  background: #f7768e;
  color: #1a1b26;
}
.chat-message pre, .chat-message code { font-family: ui-monospace, monospace; font-size: 12px; }
.chat-message pre { margin: 8px 0; padding: 10px; background: #1f2335; overflow-x: auto; border-radius: 4px; }
.chat-message code { padding: 2px 4px; background: #1f2335; border-radius: 4px; }
.chat-message p { margin: 0 0 6px 0; }
.chat-message p:last-child { margin-bottom: 0; }

/* ----- Input row (same as local .chat-input-row) ----- */
.chat-input-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #363b54;
  background: #16161e;
}
.chat-input-row textarea {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  max-height: 200px;
  padding: 8px 10px;
  border: 1px solid #363b54;
  border-radius: 6px;
  background: #1a1b26;
  color: #c0caf5;
  font-size: 13px;
  font-family: inherit;
  resize: none;
}
.chat-input-row textarea:focus { outline: none; border-color: #7aa2f7; }
.chat-input-row .btn-send {
  padding: 8px 16px;
  background: #7aa2f7;
  color: #1a1b26;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.chat-input-row .btn-send:hover { background: #89b4fa; }
.chat-input-row .btn-send:disabled { opacity: 0.6; cursor: not-allowed; }
