/* public/css/chat-usage.css — chat Idéation, usage Claude, toasts, bannière de nouvelle version (tranche contiguë de l'ancien style.css ; ordre de chargement dans index.html, cf. CLAUDE.md) */
/* ── Chat (mode Idéation, fusionné dans #intention-form) ── */
.chat-pending-indicator {
  display: block;
  margin: -6px 0 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--yellow);
  animation: blink 1s ease-in-out infinite;
}

/* Même piège de spécificité que .chat-messages ci-dessous : `display: block` (règle auteur)
   prime sur `[hidden] { display: none }` du user-agent stylesheet à spécificité égale — sans
   cette surcharge, setChatPending(false) pose bien l'attribut `hidden` mais l'indicateur reste
   affiché et continue de clignoter après réception de la réponse. */
.chat-pending-indicator[hidden] {
  display: none;
}

.btn-chat-deliver {
  background: none;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 4px 9px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: border-color 0.12s, color 0.12s;
}

.btn-chat-deliver:hover { border-color: var(--green); color: var(--green); }
.btn-chat-deliver:disabled { opacity: 0.4; cursor: not-allowed; }

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #0a0c14;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

/* Le `display: flex` ci-dessus (règle auteur) prime sur le `[hidden] { display: none }`
   du user-agent stylesheet à spécificité égale — sans cette surcharge explicite, l'attribut
   `hidden` posé par applyIntentionMode() en mode Implémentation n'a aucun effet visuel et le
   bloc chat reste affiché. */
.chat-messages[hidden] {
  display: none;
}

.chat-bubble {
  max-width: 85%;
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg2);
  border: 1px solid var(--border-light);
  color: var(--text);
  position: relative;
  padding-right: 26px;
}

.chat-bubble-copy {
  position: absolute;
  top: 4px;
  right: 5px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  padding: 2px;
  opacity: 0.6;
  transition: opacity 0.12s, color 0.12s;
}

.chat-bubble-copy:hover { opacity: 1; color: var(--text); }
.chat-bubble-copy.copied { opacity: 1; color: var(--green); }

.chat-bubble.assistant.chat-bubble--readonly {
  background: rgba(167, 139, 250, 0.08);
  border-color: rgba(167, 139, 250, 0.3);
  border-left: 3px solid var(--purple);
}

.chat-bubble-meta {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  opacity: 0.7;
}

.chat-bubble-kind {
  color: var(--purple);
  font-weight: 600;
  margin-right: 6px;
}

/* Tour 'notice' (limite de forfait — reprise programmée ou abandon après
   MAX_RATE_LIMIT_RETRIES, cf. scheduleChatRetryIfRateLimited dans server.js) — un message
   d'information du hub, pas un tour user/assistant : bulle centrée, pas d'alignement gauche/droite,
   pas de bouton copier. */
.chat-bubble.notice {
  align-self: center;
  max-width: 95%;
  background: var(--yellow-dim);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--yellow);
  text-align: center;
  font-size: 11.5px;
}

.chat-bubble.notice--exhausted {
  background: var(--red-dim);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.chat-empty { font-size: 12px; color: var(--text-muted); padding: 4px 0; }

/* Colonne : le prompt prend toute la largeur, Envoyer (mode Idéation) passe dessous, aligné à
   droite comme ▶ Lancer en mode Implémentation, et avec le même gabarit. */
.intention-input-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 12px;
}
.intention-input-row .intention-input { flex: 1; margin-bottom: 0; }
.intention-input-row #btn-chat-send {
  align-self: flex-end;
  height: 30px;
  padding: 0 18px;
  font-size: 13px;
  box-sizing: border-box;
}

/* Habillage "boîte de chat" de #intention-text en mode Idéation (togglé par
   applyIntentionMode()) — se superpose à .intention-input, qui reste toujours présente. */
.intention-input--chat {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  resize: vertical;
}

.intention-input--chat:focus { border-color: var(--accent); }

.intention-input--chat.pending {
  animation: border-pulse 2s ease-in-out infinite;
}

.cursor-blink {
  display: inline-block;
  color: var(--accent);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Claude Usage Section ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-header .section-title { margin-bottom: 0; }

.section-title-group, .projects-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-intentions-purge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(79,126,248,0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn-intentions-purge:hover { background: rgba(79,126,248,0.25); }

.usage-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.finops-section-body.collapsed { display: none; }

.btn-settings-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid rgba(79, 126, 248, 0.3);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.btn-settings-link:hover { background: var(--accent-dim); }

.btn-icon {
  background: none;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}

.btn-icon:hover { border-color: var(--accent); color: var(--accent); }

.usage-loading {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  animation: pulse 1.5s ease-in-out infinite;
}

.usage-period-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 12px;
}

.period-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.period-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.period-renewal {
  font-size: 11px;
  color: var(--text-muted);
}

.period-renewal strong { color: var(--accent); }

.period-stats {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 12px;
}

.period-tokens {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
}

.period-tokens-unit {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
}

.period-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.period-breakdown {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-muted);
}

.breakdown-item { display: flex; align-items: center; gap: 4px; }
.breakdown-dot  { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.dot-input      { background: var(--accent); }
.dot-cache-r    { background: var(--green); }
.dot-cache-w    { background: var(--yellow); }
.dot-output     { background: var(--purple); }

.usage-sessions-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}

.usage-sessions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.usage-sessions-header::-webkit-details-marker { display: none; }
.sessions-toggle-label::before { content: '▸'; font-size: 9px; display: inline-block; transition: transform 0.15s; margin-right: 5px; }
details[open] > .usage-sessions-header .sessions-toggle-label::before { transform: rotate(90deg); }

.usage-sessions-count {
  font-size: 11px;
  color: var(--accent);
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
}

.usage-sessions-list { max-height: 320px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border-light) transparent; }

.usage-session-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.usage-session-row:last-child { border-bottom: none; }
.usage-session-row:hover { background: var(--card-hover); }
.usage-session-row.in-period { border-left: 2px solid var(--accent); padding-left: 14px; }

.session-project {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-project small {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 6px;
}

.session-model {
  font-size: 10px;
  color: var(--purple);
  white-space: nowrap;
  padding: 1px 7px;
  border-radius: 20px;
  background: rgba(167, 139, 250, 0.1);
  border: 1px solid rgba(167, 139, 250, 0.2);
}

.session-time {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 70px;
  text-align: right;
}

.session-tokens {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  min-width: 50px;
  text-align: right;
}

.usage-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 24px;
}

.usage-manual-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.usage-manual-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.manual-entry-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}

.manual-input, .manual-select {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
}

.manual-input:focus, .manual-select:focus { border-color: var(--accent); }

.btn-submit-sm {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s;
}

.btn-submit-sm:hover { opacity: 0.85; }

.manual-entry-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
}

.manual-entry-item:last-child { border-bottom: none; }

.btn-del-manual {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  margin-left: auto;
  transition: color 0.15s;
}

.btn-del-manual:hover { color: var(--red); }

.usage-config-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.config-label {
  font-size: 12px;
  color: var(--text-muted);
}

.renewal-input {
  background: var(--bg2);
  border: 1px solid var(--border-light);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  width: 56px;
  text-align: center;
  font-family: inherit;
  outline: none;
}

.renewal-input:focus { border-color: var(--accent); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card);
  border: 1px solid var(--border-light);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 100;
  transform: translateY(0);
  opacity: 1;
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.toast.hide { opacity: 0; transform: translateY(8px); }
.toast.success { border-color: rgba(34, 197, 94, 0.4); color: var(--green); }
.toast.error { border-color: rgba(239, 68, 68, 0.4); color: var(--red); }
.toast.warn { border-color: rgba(245, 158, 11, 0.4); color: var(--yellow); }
.toast.persistent { display: flex; align-items: center; gap: 12px; max-width: 420px; }
.toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px;
  flex-shrink: 0;
}
.toast-close:hover { opacity: 1; }

/* ── App update banner (persistent, unlike .toast) ── */
.app-update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  font-size: 13px;
  z-index: 300;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}
.app-update-banner button {
  background: #fff;
  color: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

