/* AI Usage Relay extension page */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0a0a0a;
  color: #e8e8e8;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

/* ── Nav ─────────────────────────────────────────────────────────────────── */
nav {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 24px; border-bottom: 1px solid #1a1a1a; font-size: 0.82rem;
  position: sticky; top: 0; background: rgba(10,10,10,0.97);
  backdrop-filter: blur(8px); z-index: 50;
}
nav a { color: #555; text-decoration: none; transition: color 0.2s; }
nav a:hover { color: #f0f0f0; }
nav .sep { color: #333; }
nav .current { color: #e0e0e0; }
nav .spacer { flex: 1; }

#nav-auth { position: relative; }
#nav-auth-btn {
  background: none; border: 1px solid #252525; border-radius: 6px;
  color: #444; font-size: 0.75rem; padding: 4px 10px; cursor: pointer;
  font-family: inherit; transition: color 0.2s, border-color 0.2s;
  text-decoration: none; display: inline-block; line-height: 1.6;
}
#nav-auth-btn:hover { color: #888; border-color: #333; }
#nav-auth-btn.authed { color: #4ade80; border-color: rgba(74,222,128,0.25); }
#nav-auth-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  background: #111; border: 1px solid #222; border-radius: 8px;
  min-width: 180px; z-index: 200; overflow: hidden;
}
#nav-auth-dropdown.open { display: block; }
.nav-dd-item {
  display: block; width: 100%; padding: 9px 14px; font-size: 0.8rem;
  color: #888; text-decoration: none; background: none; border: none;
  text-align: left; cursor: pointer; font-family: inherit; transition: background 0.15s, color 0.15s;
}
.nav-dd-item:hover { background: #161616; color: #ccc; }
.nav-dd-item.danger:hover { color: #f87171; }

/* ── Chat bubble ─────────────────────────────────────────────────────────── */
#chat-bubble {
  position: fixed; bottom: 24px; right: 24px; z-index: 900;
  width: 48px; height: 48px; border-radius: 50%;
  background: #1a1a1a; border: 1px solid #2a2a2a;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: #555; transition: color 0.2s, border-color 0.2s, transform 0.2s;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
#chat-bubble:hover { color: #4ade80; border-color: rgba(74,222,128,0.3); transform: scale(1.05); }
#chat-panel {
  position: fixed; bottom: 84px; right: 24px; z-index: 901;
  width: 340px; max-height: 480px;
  background: #111; border: 1px solid #1e1e1e; border-radius: 12px;
  display: none; flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6); overflow: hidden;
}
#chat-panel.open { display: flex; }
#chat-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid #1a1a1a;
  font-size: 0.82rem; color: #888;
}
#chat-messages {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 200px; max-height: 320px;
  font-size: 0.82rem; line-height: 1.5;
}
.chat-msg-user {
  align-self: flex-end; background: #1a1a1a; border-radius: 10px 10px 2px 10px;
  padding: 8px 12px; color: #d0d0d0; max-width: 85%;
}
.chat-msg-ai { align-self: flex-start; color: #aaa; max-width: 90%; }
.chat-msg-ai.streaming::after { content: '\25ae'; animation: blink 0.8s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
#chat-input-row { display: flex; padding: 10px 12px; gap: 8px; border-top: 1px solid #1a1a1a; }
#chat-input {
  flex: 1; background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 6px;
  color: #e0e0e0; font-size: 0.82rem; padding: 8px 10px; outline: none; font-family: inherit;
}
#chat-input:focus { border-color: #333; }
#chat-send {
  background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 6px;
  color: #555; padding: 8px 12px; cursor: pointer; font-size: 1rem; transition: color 0.2s;
}
#chat-send:hover { color: #4ade80; border-color: rgba(74,222,128,0.2); }

/* ── Status panel ────────────────────────────────────────────────────────── */
.ext-status-panel {
  max-width: 760px;
  margin: 0 auto 0;
  padding: 0 24px 32px;
}
.ext-status-panel.hidden { display: none; }

.ext-status-header {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 14px;
}
.ext-status-title {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: #4ade80;
}
.ext-status-subtitle { font-size: 0.75rem; color: #444; }

.ext-status-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
}
@media (max-width: 640px) { .ext-status-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 400px) { .ext-status-grid { grid-template-columns: 1fr; } }

.ext-status-card {
  background: #0e0e0e; border: 1px solid #1e1e1e;
  border-radius: 10px; padding: 16px 18px;
}
.ext-status-card-label {
  font-size: 0.78rem; font-weight: 600; color: #aaa; margin-bottom: 10px;
}
.ext-status-dot-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.ext-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #333; flex-shrink: 0;
  transition: background 0.3s;
}
.ext-status-dot.ok    { background: #4ade80; box-shadow: 0 0 6px rgba(74,222,128,0.4); }
.ext-status-dot.warn  { background: #f59e0b; box-shadow: 0 0 6px rgba(245,158,11,0.4); }
.ext-status-dot.stale { background: #f87171; box-shadow: 0 0 6px rgba(248,113,113,0.3); }
.ext-status-dot.never { background: #333; }

.ext-status-state { font-size: 0.82rem; font-weight: 600; color: #555; }
.ext-status-state.ok    { color: #4ade80; }
.ext-status-state.warn  { color: #f59e0b; }
.ext-status-state.stale { color: #f87171; }

.ext-status-ts   { font-size: 0.75rem; color: #444; line-height: 1.5; }
.ext-status-creds {
  margin-top: 8px; font-size: 0.72rem; color: #333;
  border-top: 1px solid #1a1a1a; padding-top: 8px;
}
.ext-status-creds.present { color: #4ade80; }

/* ── Hero ─────────────────────────────────────────────────────────────────── */
.ext-hero {
  text-align: center;
  padding: 64px 24px 48px;
  max-width: 680px;
  margin: 0 auto;
}

.ext-hero-icon {
  margin-bottom: 20px;
}

.ext-hero-icon img {
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(74,222,128,0.15);
}

.ext-hero-kicker {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #4ade80;
  margin-bottom: 12px;
}

.ext-hero-title {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
  line-height: 1.2;
}

.ext-hero-sub {
  font-size: 1rem;
  color: #888;
  line-height: 1.7;
  max-width: 520px;
  margin: 0 auto 24px;
}

.ext-hero-sub a { color: #4ade80; text-decoration: none; }
.ext-hero-sub a:hover { text-decoration: underline; }

.ext-version-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ext-version-badge {
  background: #161616;
  border: 1px solid #2a2a2a;
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.78rem;
  color: #4ade80;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.ext-version-note {
  font-size: 0.78rem;
  color: #555;
  max-width: 400px;
  text-align: left;
}

/* ── Content ──────────────────────────────────────────────────────────────── */
.ext-content {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px 80px;
}

.ext-section {
  margin-bottom: 56px;
}

.ext-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #4ade80;
  margin-bottom: 16px;
}

.ext-section-intro {
  color: #888;
  margin-bottom: 20px;
  max-width: 600px;
}

/* ── Flow ─────────────────────────────────────────────────────────────────── */
.ext-flow {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.ext-flow-step {
  flex: 1;
  min-width: 180px;
  background: #111;
  border: 1px solid #1e1e1e;
  border-radius: 12px;
  padding: 20px;
}

.ext-flow-icon {
  font-size: 1.5rem;
  margin-bottom: 10px;
}

.ext-flow-text {
  font-size: 0.85rem;
  color: #888;
  line-height: 1.6;
}

.ext-flow-text strong {
  display: block;
  color: #e8e8e8;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.ext-flow-arrow {
  color: #333;
  font-size: 1.2rem;
  padding-top: 28px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .ext-flow-arrow { display: none; }
  .ext-flow { flex-direction: column; }
}

/* ── Permissions ──────────────────────────────────────────────────────────── */
.ext-perms {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid #1e1e1e;
  border-radius: 10px;
  overflow: hidden;
}

.ext-perm {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  padding: 14px 18px;
  background: #0e0e0e;
  font-size: 0.84rem;
}

.ext-perm:nth-child(odd) { background: #111; }

.ext-perm-name {
  color: #e8e8e8;
  font-weight: 500;
  padding-top: 1px;
}

.ext-perm-name code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem;
  color: #a78bfa;
}

.ext-perm-desc {
  color: #666;
  line-height: 1.55;
}

.ext-perm-desc code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  color: #888;
  background: #1a1a1a;
  padding: 1px 5px;
  border-radius: 3px;
}

@media (max-width: 600px) {
  .ext-perm { grid-template-columns: 1fr; gap: 4px; }
}

/* ── Steps ────────────────────────────────────────────────────────────────── */
.ext-steps {
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ext-steps li {
  color: #888;
  font-size: 0.9rem;
  line-height: 1.6;
  padding-left: 4px;
}

.ext-steps li strong {
  color: #e8e8e8;
  display: block;
  margin-bottom: 2px;
}

.ext-steps code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  color: #888;
  background: #1a1a1a;
  padding: 1px 6px;
  border-radius: 3px;
}

.ext-note {
  margin-top: 16px;
  font-size: 0.82rem;
  color: #555;
  border-left: 2px solid #2a2a2a;
  padding-left: 12px;
}

/* ── Download button ──────────────────────────────────────────────────────── */
.ext-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 20px;
  background: #4ade80;
  color: #0a0a0a;
  border: none;
  border-radius: 8px;
  font: 600 0.9rem/1 inherit;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}

.ext-download-btn:hover {
  background: #22c55e;
  transform: translateY(-1px);
}

.ext-dl-version {
  font-size: 0.75rem;
  font-weight: 400;
  opacity: 0.7;
}

.ext-login-hint {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.82rem;
  color: #555;
}

/* ── Store assets ─────────────────────────────────────────────────────────── */
.ext-assets {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 28px;
}

.ext-asset {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ext-asset-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #555;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.ext-asset-wrap {
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.ext-asset-wrap img {
  display: block;
  border-radius: 8px;
  border: 1px solid #1e1e1e;
  max-width: 100%;
}

.ext-asset-screenshots {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.ext-asset-screenshots .ext-asset-wrap img {
  width: 320px;
  height: 200px;
  object-fit: cover;
}

.ext-asset-dl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #4ade80;
  text-decoration: none;
  opacity: 0.8;
  transition: opacity 0.15s;
}
.ext-asset-dl:hover { opacity: 1; }

/* ── Troubleshooting ──────────────────────────────────────────────────────── */
.ext-trouble {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid #1e1e1e;
  border-radius: 10px;
  overflow: hidden;
}

.ext-trouble-q {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e8e8e8;
  padding: 16px 18px 6px;
  background: #111;
}

.ext-trouble-a {
  font-size: 0.84rem;
  color: #666;
  padding: 0 18px 16px;
  background: #111;
  line-height: 1.6;
  border-bottom: 1px solid #1a1a1a;
}

.ext-trouble-a code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  color: #888;
  background: #1a1a1a;
  padding: 1px 5px;
  border-radius: 3px;
}
