/* ═══ Loading indicators ═══ */

/* Thin progress bar on top of the viewport while live-loader is fetching. */
body.cc-loading::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    oklch(0.62 0.14 245) 40%,
    oklch(0.72 0.16 245) 50%,
    oklch(0.62 0.14 245) 60%,
    transparent 100%
  );
  background-size: 40% 100%;
  animation: cc-progress 1.1s infinite linear;
  z-index: 10002;
  pointer-events: none;
}

@keyframes cc-progress {
  0%   { background-position: -40% 0; }
  100% { background-position: 140% 0; }
}

/* Soft dim of the main app while refreshing, so "stale" numbers don't look
   like the truth. Transitions so it doesn't flash for fast responses. */
body.cc-loading #app {
  opacity: 0.55;
  transition: opacity 160ms ease 120ms;
  pointer-events: none;
}
body #app {
  transition: opacity 160ms ease;
}

/* Small spinner inside the inline identity chip while refreshing data. */
body.cc-loading .identity-inline .live-dot {
  animation: cc-spin 0.7s infinite linear;
  border: 1px solid var(--fg-3);
  background: transparent;
}
@keyframes cc-spin {
  to { transform: rotate(360deg); }
}

/* Clariro — chat widget. Respeta la paleta oklch del prototype. */
#cc-chat-root {
  position: fixed;
  z-index: 10000;
  right: 24px;
  bottom: 24px;
  font-family: Inter, system-ui, sans-serif;
}

#cc-chat-toggle {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 24px;
  border: 1px solid var(--border, #2a2d32);
  background: var(--panel, #17191c);
  color: var(--text, #e6e8ea);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

#cc-chat-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.34);
}

.cc-chat-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: oklch(0.70 0.14 42);
  box-shadow: 0 0 0 2px var(--panel, #17191c);
}

#cc-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 84px;
  width: 420px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--panel, #17191c);
  color: var(--text, #e6e8ea);
  border: 1px solid var(--border, #2a2d32);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

#cc-chat-panel[hidden] { display: none; }

#cc-chat-panel > header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, #2a2d32);
  background: var(--surface, #1b1d20);
}

.cc-chat-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.cc-chat-id strong {
  font-size: 13px;
  letter-spacing: 0.01em;
}

.cc-chat-id #cc-chat-who {
  font-size: 11px;
  color: var(--text-dim, #9aa0a6);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cc-chat-status {
  display: flex;
  gap: 6px;
}

.cc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border, #2a2d32);
  display: inline-block;
  transition: background 160ms ease;
}

.cc-dot.on {
  background: oklch(0.72 0.14 155);
  box-shadow: 0 0 0 1px oklch(0.55 0.12 155);
}

#cc-chat-close {
  border: none;
  background: transparent;
  color: var(--text-dim, #9aa0a6);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}

#cc-chat-close:hover {
  background: var(--bg, #0e1013);
  color: var(--text, #e6e8ea);
}

#cc-chat-user {
  margin: 10px 14px 0;
  padding: 6px 8px;
  background: var(--surface, #1b1d20);
  color: var(--text, #e6e8ea);
  border: 1px solid var(--border, #2a2d32);
  border-radius: 6px;
  font: 12px 'JetBrains Mono', monospace;
}

#cc-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
}

.cc-msg {
  font-size: 13px;
  line-height: 1.5;
  padding: 8px 11px;
  border-radius: 8px;
  max-width: 88%;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.cc-msg-user {
  align-self: flex-end;
  background: oklch(0.34 0.08 245);
  color: var(--text, #e6e8ea);
}

.cc-msg-assistant {
  align-self: flex-start;
  background: var(--surface, #1b1d20);
  border: 1px solid var(--border, #2a2d32);
}

.cc-msg-system {
  align-self: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-dim, #9aa0a6);
  max-width: 100%;
  text-align: center;
  padding: 4px 8px;
  background: transparent;
}

.cc-msg-error {
  align-self: flex-start;
  background: oklch(0.30 0.10 22);
  color: oklch(0.90 0.04 22);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
}

.cc-thinking {
  opacity: 0.6;
  font-style: italic;
}

#cc-chat-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border, #2a2d32);
}

#cc-chat-input {
  flex: 1;
  resize: none;
  padding: 8px 10px;
  font: 13px Inter, system-ui, sans-serif;
  background: var(--bg, #0e1013);
  color: var(--text, #e6e8ea);
  border: 1px solid var(--border, #2a2d32);
  border-radius: 6px;
  outline: none;
}

#cc-chat-input:focus {
  border-color: oklch(0.55 0.12 245);
}

#cc-chat-send {
  padding: 0 14px;
  background: oklch(0.55 0.12 245);
  color: var(--text, #e6e8ea);
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease;
}

#cc-chat-send:hover:not(:disabled) {
  background: oklch(0.60 0.14 245);
}

#cc-chat-send:disabled {
  opacity: 0.5;
  cursor: wait;
}

[data-theme='light'] #cc-chat-toggle,
[data-theme='light'] #cc-chat-panel {
  background: #ffffff;
  color: #14161a;
  border-color: #e5e7eb;
}

[data-theme='light'] #cc-chat-panel > header {
  background: #f6f7f9;
  border-color: #e5e7eb;
}

[data-theme='light'] .cc-msg-assistant {
  background: #f6f7f9;
  border-color: #e5e7eb;
}

[data-theme='light'] #cc-chat-input {
  background: #ffffff;
  color: #14161a;
  border-color: #d8dbdf;
}
