/* Shared topbar — see common.js's initTopbar(). Styling reference:
   otto-pro-max's SN-branded header (dark navy #032D42 bar + white SN logo). */

/* Color tokens: light values in :root, dark values applied both by system
   preference (@media) and by the manual toggle (common.js's initThemeToggle,
   which sets html[data-theme]) — the explicit attribute always wins over the
   media query in either direction so the toggle can override system
   preference, not just follow it. --color-brand* stay constant across
   themes since they're solid button/topbar backgrounds, not text-on-bg. */
:root {
  --color-bg: #f8f8f8;
  --color-surface: #ffffff;
  --color-surface-alt: #fafafa;
  --color-text: #1a1a1a;
  --color-text-muted: #666666;
  --color-text-faint: #777777;
  --color-border: #dddddd;
  --color-border-soft: #eeeeee;
  --color-input-border: #cccccc;
  --color-shadow: rgba(0, 0, 0, .06);
  --color-shadow-strong: rgba(0, 0, 0, .15);
  --color-accent-text: #032D42;
  --color-accent-soft: #f0f4f6;
  --color-success: #157347;
  --color-danger: #b02a37;
  --color-warning: #997404;
  --color-brand: #032D42;
  --color-brand-hover: #021E2D;
  /* Single source of truth for the topbar's height — referenced by .topbar
     itself and by any page (see studio.html's .studio-page) that needs a
     hard "rest of the viewport" height instead of relying on body's
     min-height, which is a floor that grows for tall content rather than a
     ceiling that clips it. */
  --topbar-height: 52px;
}

@media (prefers-color-scheme: dark) {
  :root { --color-bg: #16191c; --color-surface: #1e2226; --color-surface-alt: #252a2f;
    --color-text: #e8eaed; --color-text-muted: #a3acb5; --color-text-faint: #8a939c;
    --color-border: #333a41; --color-border-soft: #2b3136; --color-input-border: #454d55;
    --color-shadow: rgba(0, 0, 0, .3); --color-shadow-strong: rgba(0, 0, 0, .5);
    --color-accent-text: #7fb4e3; --color-accent-soft: #1e2f3d;
    --color-success: #4fc78e; --color-danger: #f2707c; --color-warning: #f0c419; }
}
:root[data-theme="light"] {
  --color-bg: #f8f8f8; --color-surface: #ffffff; --color-surface-alt: #fafafa;
  --color-text: #1a1a1a; --color-text-muted: #666666; --color-text-faint: #777777;
  --color-border: #dddddd; --color-border-soft: #eeeeee; --color-input-border: #cccccc;
  --color-shadow: rgba(0, 0, 0, .06); --color-shadow-strong: rgba(0, 0, 0, .15);
  --color-accent-text: #032D42; --color-accent-soft: #f0f4f6;
  --color-success: #157347; --color-danger: #b02a37; --color-warning: #997404;
}
:root[data-theme="dark"] {
  --color-bg: #16191c; --color-surface: #1e2226; --color-surface-alt: #252a2f;
  --color-text: #e8eaed; --color-text-muted: #a3acb5; --color-text-faint: #8a939c;
  --color-border: #333a41; --color-border-soft: #2b3136; --color-input-border: #454d55;
  --color-shadow: rgba(0, 0, 0, .3); --color-shadow-strong: rgba(0, 0, 0, .5);
  --color-accent-text: #7fb4e3; --color-accent-soft: #1e2f3d;
  --color-success: #4fc78e; --color-danger: #f2707c; --color-warning: #f0c419;
}

* { box-sizing: border-box; }
/* A flex column exactly one viewport tall, topbar pinned to its natural
   height, .page taking the rest — so any page's height-sensitive content
   (see studio.html's .studio-page) can fill "the rest of the viewport"
   without a hand-picked px offset that drifts out of sync with the topbar. */
html { height: 100%; }
body { font-family: -apple-system, system-ui, sans-serif; margin: 0; color: var(--color-text); background: var(--color-bg); display: flex; flex-direction: column; min-height: 100%; }

.status-succeeded { color: var(--color-success); }
.status-failed { color: var(--color-danger); }
.status-building, .status-validating, .status-provisioning_db, .status-deploying, .status-routing { color: var(--color-warning); }
.status-draft { color: var(--color-text-muted); }

.topbar {
  background: var(--color-brand);
  height: var(--topbar-height);
  flex-shrink: 0;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
}
.theme-toggle {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .35);
  color: #fff;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { background: rgba(255, 255, 255, .1); }
.topbar-logo { height: 18px; width: auto; display: block; flex-shrink: 0; }
.topbar-badge {
  color: #fff;
  font-size: 12px;
  padding: 3px 10px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.topbar-nav { display: flex; gap: 2px; flex: 1; min-width: 0; }
.topbar-link {
  color: rgba(255, 255, 255, .7);
  text-decoration: none;
  font-size: 14px;
  padding: 7px 12px;
  border-radius: 6px;
  white-space: nowrap;
}
.topbar-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.topbar-link.active { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; }
.topbar-auth {
  color: rgba(255, 255, 255, .85);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.topbar-auth button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .35);
  color: #fff;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  margin: 0;
}
.topbar-auth button:hover { background: rgba(255, 255, 255, .1); }
.topbar-signin { color: #fff; font-size: 13px; text-decoration: underline; }

.page { padding: 20px 24px; flex: 1; min-height: 0; width: 100%; }
.page-narrow { max-width: 960px; margin: 0 auto; }

/* Shared sign-in/sign-up card — see common.js's wireAuthForm(). */
.auth-card {
  max-width: 380px;
  margin: 48px auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 28px 28px 22px;
  box-shadow: 0 1px 3px var(--color-shadow);
}
.auth-card h2 { margin: 0 0 6px; font-size: 19px; color: var(--color-text); }
.auth-card .auth-sub { margin: 0 0 20px; color: var(--color-text-muted); font-size: 13px; }
.auth-card label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 14px 0 4px;
}
.auth-card input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--color-input-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text);
}
.auth-forgot-link { display: inline-block; margin-top: 8px; font-size: 12px; color: var(--color-accent-text); text-decoration: none; }
.auth-forgot-link:hover { text-decoration: underline; }
.auth-actions { display: flex; gap: 10px; margin-top: 20px; }
.auth-actions button {
  flex: 1;
  margin: 0;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
}
.auth-primary { background: var(--color-brand); color: #fff; border: none; }
/* Specificity has to clear each page's own `button:hover:not(:disabled)`
   rule (0,2,1) — a two-class-selector hover is (0,3,0), which wins
   regardless of stylesheet order (same class of bug as .hidden elsewhere). */
.auth-actions .auth-primary:hover,
.change-password-panel .auth-primary:hover { background: var(--color-brand-hover); }
.auth-secondary { background: var(--color-surface); color: var(--color-accent-text); border: 1px solid var(--color-accent-text); }
.auth-actions .auth-secondary:hover { background: var(--color-accent-soft); }
.auth-card .status { min-height: 16px; margin-top: 12px; color: var(--color-text-muted); }

.change-password-panel {
  position: absolute;
  top: 52px;
  right: 20px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 16px var(--color-shadow-strong);
  padding: 16px;
  width: 260px;
  z-index: 100;
  text-align: left;
}
.change-password-panel label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 10px 0 4px;
}
.change-password-panel label:first-child { margin-top: 0; }
.change-password-panel input {
  width: 100%;
  box-sizing: border-box;
  padding: 7px 8px;
  font-size: 13px;
  font-family: inherit;
  border: 1px solid var(--color-input-border);
  border-radius: 5px;
  background: var(--color-surface);
  color: var(--color-text);
}
.change-password-panel button { width: 100%; margin: 14px 0 0; padding: 8px; }
.change-password-panel .status { color: var(--color-text-muted); font-size: 12px; margin-top: 8px; }
