/* Dashboard-specific styles */

.auth-section,
.dashboard-section {
  padding: 3rem 0;
  min-height: calc(100vh - var(--header-h) - 4rem);
}

.auth-panel {
  max-width: 420px;
  margin: 2rem auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
}

.auth-panel h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
}

.auth-lead {
  margin: 0 0 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 1rem;
}

.auth-status {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

#auth-notice {
  margin-bottom: 1.25rem;
}

.auth-error {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.85rem;
  background: rgba(240, 100, 100, 0.15);
  border: 1px solid rgba(240, 100, 100, 0.35);
  border-radius: 6px;
  color: #f0a0a0;
  font-size: 0.85rem;
}

.dashboard-grid {
  display: grid;
  gap: 1.5rem;
  margin-top: 2rem;
  /* minmax(0, …): long code/URLs inside a card must not widen the track past the viewport */
  grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 768px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.card {
  min-width: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.35rem;
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.profile-info,
.usage-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.info-value {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.loading-state {
  padding: 1rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loading-section {
  padding: 4rem 0;
  text-align: center;
  min-height: calc(100vh - var(--header-h));
}

.loading-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 1rem;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.notice {
  padding: 1rem 1.1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.notice p {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.notice p:last-child {
  margin-bottom: 0;
}

.notice-info {
  background: rgba(61, 214, 198, 0.1);
  border: 1px solid rgba(61, 214, 198, 0.3);
  color: var(--text);
}

.notice-warning {
  background: rgba(232, 184, 74, 0.1);
  border: 1px solid rgba(232, 184, 74, 0.3);
  color: var(--text);
}

.notice-footer {
  font-size: 0.8rem !important;
  color: var(--text-muted) !important;
}

.key-display {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin: 0.75rem 0;
  padding: 0.75rem 0.85rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.key-display code {
  flex: 1;
  font-size: 0.85rem;
  word-break: break-all;
  color: var(--accent);
}

.key-note {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.usage-stat {
  text-align: center;
  padding: 1.5rem 0 1rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.75rem;
}

.stat-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.usage-list {
  max-height: 300px;
  overflow-y: auto;
}

.usage-item {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.85rem;
}

.usage-item:last-child {
  border-bottom: none;
}

.usage-date {
  color: var(--text-muted);
}

.usage-count {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 500;
}

/* —— API key mask —— */
.key-display code.key-masked {
  letter-spacing: 0.02em;
}

/* —— Try it out —— */
/* Some panels set display (flex/grid); keep the hidden attribute authoritative. */
.tryit [hidden] {
  display: none !important;
}

.card-wide {
  grid-column: 1 / -1;
}

.tryit-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1rem;
  margin-bottom: 1rem;
}

.tryit-head h2 {
  margin: 0;
}

.tryit-note {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.tryit-form .form-field {
  margin-bottom: 0.9rem;
}

.tryit-row {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}

.tryit-row input {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
}

.tryit-hint {
  margin: 0.4rem 0 0;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.tryit-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.6rem;
}

.chip {
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.chip:hover,
.chip.active {
  border-color: var(--accent-dim);
  color: var(--accent);
  background: var(--accent-bg);
}

.tryit-request {
  margin-top: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  overflow: hidden;
}

.tryit-request-line {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  overflow-x: auto;
}

.tryit-request-line code {
  color: var(--text);
  white-space: nowrap;
}

.http-method {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  color: #061018;
  background: var(--accent);
}

.tryit-curl {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem;
}

.tryit-curl pre {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow-x: auto;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-muted);
}

.tryit-curl-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.tryit-error {
  margin-top: 1rem;
  padding: 0.7rem 0.9rem;
  background: rgba(240, 100, 100, 0.12);
  border: 1px solid rgba(240, 100, 100, 0.35);
  border-radius: 8px;
  color: #f0b0b0;
  font-size: 0.85rem;
}

.tryit-error strong {
  color: #f4c4c4;
}

.tryit-error .tryit-error-detail {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.tryit-result {
  margin-top: 1rem;
}

.tryit-result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.tabs {
  display: inline-flex;
  padding: 0.2rem;
  gap: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.tab {
  padding: 0.3rem 0.85rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 560;
  cursor: pointer;
}

.tab[aria-selected="true"] {
  background: var(--bg-card);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--border);
}

.tryit-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
}

.status-pill {
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  border: 1px solid var(--border);
}

.status-pill.ok {
  color: var(--accent);
  border-color: rgba(61, 214, 198, 0.4);
  background: var(--accent-bg);
}

.status-pill.warn {
  color: var(--warn);
  border-color: rgba(232, 184, 74, 0.4);
  background: rgba(232, 184, 74, 0.08);
}

.status-pill.err {
  color: #f0a0a0;
  border-color: rgba(240, 100, 100, 0.4);
  background: rgba(240, 100, 100, 0.1);
}

.tryit-raw {
  margin: 0;
  max-height: 480px;
  overflow: auto;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--code-bg);
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-all;
}

.tryit-pretty {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.pretty-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.pretty-summary-item {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
}

.pretty-summary-item .k {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pretty-summary-item .v {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
}

.pretty-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .pretty-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  }
}

.pretty-section {
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  min-width: 0;
}

.pretty-section h3 {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.pretty-rows {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 0.3rem 0.9rem;
  font-size: 0.83rem;
}

.pretty-rows dt {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-dim);
  padding-top: 0.08rem;
}

.pretty-rows dd {
  margin: 0;
  color: var(--text);
  word-break: break-word;
  text-align: right;
}

.pretty-rows dd.null {
  color: var(--text-dim);
}

.pretty-rows dd .pretty-rows {
  margin-top: 0.2rem;
  text-align: left;
}

.pretty-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pretty-rows + .pretty-badges {
  margin-top: 0.7rem;
}

.flag-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-dim);
}

.flag-badge::before {
  content: "";
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--border);
}

.flag-badge.on {
  color: var(--accent);
  border-color: rgba(61, 214, 198, 0.45);
  background: var(--accent-bg);
}

.flag-badge.on::before {
  background: var(--accent);
}

@media (max-width: 560px) {
  .tryit-curl {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Buttons set display:inline-flex, which would override [hidden] (e.g. Logout
   while signed out). Keep the attribute authoritative in the header and key card. */
.site-header [hidden],
.auth-panel [hidden],
#key-content [hidden] {
  display: none !important;
}

.key-warn {
  color: var(--warn);
}

.key-legacy-notice {
  margin-top: 0.85rem;
}

#key-actions {
  margin-top: 0.9rem;
}

.tryit-save {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  margin-top: 0.5rem;
}

.tryit-save .tryit-hint {
  margin: 0;
}

/* The dashboard header has only two items (API Docs, Logout) and no hamburger
   toggle, so keep the nav inline on small screens instead of the collapsed menu. */
@media (max-width: 720px) {
  .site-header .nav {
    display: flex;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
  }
  .site-header .nav a {
    padding: 0;
    font-size: 0.9rem;
  }
  .site-header .nav .btn-sm {
    margin: 0;
    width: auto;
  }
}
