/* AI Usage modal — shows the shared AI-credit balance against the tier's
   cycle allotment, plus a per-feature lifetime-usage breakdown. */

.ai-usage-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 2000;
}

.ai-usage-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2001;
  padding:
    max(14px, calc(var(--safe-top-inset, env(safe-area-inset-top, 0px)) + 10px))
    14px
    max(14px, calc(var(--safe-bottom-inset, env(safe-area-inset-bottom, 0px)) + 8px));
  pointer-events: none;
}

.ai-usage-modal-inner {
  background: var(--panel-solid, #0c1926);
  color: var(--ink, #eff8ff);
  border: 1px solid var(--line, rgba(143, 170, 192, 0.22));
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 80vh;
  overflow-y: auto;
  pointer-events: all;
  transform: translateY(24px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.2s ease;
  box-shadow: 0 20px 60px var(--shadow, rgba(0, 0, 0, 0.45));
}

.ai-usage-modal.is-open .ai-usage-modal-inner {
  transform: translateY(0);
  opacity: 1;
}

/* Header */
.ai-usage-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line, rgba(143, 170, 192, 0.16));
}

.ai-usage-modal-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
}

.ai-usage-close-btn {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.9rem;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  color: var(--muted);
  flex-shrink: 0;
}

/* Body sections */
.ai-usage-modal-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ai-usage-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-usage-section-head {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}

.ai-usage-section-head h3 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Balance hero (the shared credit total) — sits above the section list */
.ai-usage-balance-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-usage-balance-note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.ai-usage-row-note {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Individual quota rows */
.ai-usage-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-usage-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ai-usage-row--balance .ai-usage-row-label {
  font-size: 1rem;
  font-weight: 600;
}

.ai-usage-row--balance .ai-usage-row-count {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.ai-usage-row-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.ai-usage-row-label {
  font-size: 0.88rem;
  color: var(--ink);
}

.ai-usage-row-count {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Progress bar */
.ai-usage-bar-track {
  height: 6px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ink) 12%, transparent);
  overflow: hidden;
}

.ai-usage-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent, #4a9eff);
  transition: width 0.4s ease;
}

.ai-usage-bar-fill--warning {
  background: #e6963a;
}

.ai-usage-bar-fill--danger {
  background: var(--danger, #e05252);
}

/* Buy-more-credits section */
.ai-usage-buy-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-usage-buy-btn {
  width: 100%;
  padding: 10px var(--space-md);
  font-size: 0.88rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--accent, #4a9eff) 14%, transparent);
  color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--accent, #4a9eff) 40%, transparent);
  border-radius: 10px;
}

.ai-usage-buy-btn:active {
  opacity: 0.85;
}

.ai-usage-buy-btn:disabled {
  opacity: 0.6;
}

.ai-usage-buy-note {
  margin: 4px 0 0;
  font-size: 0.76rem;
  color: var(--muted);
}

/* State messages */
.ai-usage-loading,
.ai-usage-error,
.ai-usage-unavailable,
.ai-usage-unlimited {
  font-size: 0.88rem;
  color: var(--muted);
  padding: 4px 0;
}

.ai-usage-error { color: var(--danger, #e05252); }

/* Footer upgrade CTA */
.ai-usage-modal-footer {
  padding: 4px 20px 20px;
}

.ai-usage-upgrade-btn {
  width: 100%;
  padding: var(--space-md);
  font-size: 0.92rem;
  font-weight: 600;
  background: var(--accent, #4a9eff);
  color: #fff;
  border-radius: 10px;
  border: none;
}

.ai-usage-upgrade-btn:active {
  opacity: 0.85;
}
