/*
 * Visual language for the self-service console — copied from
 * webui/mockups/shared.css (the approved mockups) rather than
 * reimplemented from scratch, so what ships matches what was reviewed.
 * Kept as its own file (not imported from webui/site/, the admin
 * console) per the "two thin frontends, not one role-branching bundle"
 * decision — the two consoles' CSS is allowed to drift independently.
 */

:root {
  color-scheme: light dark;
  --ink: #14181c;
  --ink-soft: #4b5560;
  --paper: #ffffff;
  --paper-sunken: #f4f6f8;
  --line: #e2e6ea;
  --accent: #0f6fde;
  --accent-ink: #ffffff;
  --accent-soft: #e8f1fd;
  --good: #1a8a4a;
  --good-soft: #e7f6ed;
  --warn: #b45309;
  --warn-soft: #fdf2e2;
  --bad: #c22b2b;
  --bad-soft: #fdeaea;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 1px 2px rgba(20, 24, 28, 0.04), 0 8px 24px rgba(20, 24, 28, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper-sunken);
  -webkit-font-smoothing: antialiased;
}

.screen {
  min-height: 100vh;
  padding: 20px 16px 48px;
  max-width: 480px;
  margin: 0 auto;
  box-sizing: border-box;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--ink); display: flex; align-items: center; justify-content: center;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--ink);
  color: white; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; cursor: pointer; border: none;
}

.card {
  width: 100%;
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 28px 24px;
  box-sizing: border-box;
}
.card + .card { margin-top: 14px; }

h1.title { font-size: 22px; font-weight: 700; margin: 0 0 6px; letter-spacing: -0.01em; }
p.subtitle { font-size: 14.5px; color: var(--ink-soft); margin: 0 0 22px; line-height: 1.5; }

label.field-label {
  display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 7px;
}
.field { margin-bottom: 16px; }

select.control, input.control, textarea.control {
  width: 100%; font-family: var(--font); font-size: 16px; padding: 13px 14px;
  border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  background: var(--paper); color: var(--ink); appearance: none;
}
select.control:focus, input.control:focus, textarea.control:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

button.btn {
  width: 100%; font-family: var(--font); font-size: 16px; font-weight: 600;
  padding: 14px 18px; border-radius: var(--radius-sm); border: none;
  cursor: pointer; transition: transform 0.05s ease, opacity 0.15s ease;
}
button.btn:active { transform: scale(0.99); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-secondary { background: var(--paper-sunken); color: var(--ink); border: 1.5px solid var(--line); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
button.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  font-weight: 600; padding: 5px 11px 5px 8px; border-radius: 999px;
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; }

.status-card { background: var(--ink); color: white; border-radius: var(--radius-lg); padding: 22px 22px 20px; margin-bottom: 16px; }
.status-top-row { display: flex; justify-content: space-between; align-items: flex-start; }
.status-name { font-size: 13px; opacity: 0.65; margin-bottom: 4px; }
.status-headline { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.status-battery { text-align: right; }
.battery-pct { font-size: 22px; font-weight: 700; }
.battery-label { font-size: 11.5px; opacity: 0.6; }
.status-meta-row { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; opacity: 0.85; }

.badge-preview {
  margin-top: 18px; background: white; border-radius: 10px; aspect-ratio: 400/300;
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--ink);
}
.badge-preview .name { font-size: 15px; font-weight: 700; }
.badge-preview .title { font-size: 10px; color: var(--ink-soft); margin-top: 3px; }
.badge-preview .rule { width: 60%; height: 1px; background: var(--line); margin: 8px 0; }
.badge-preview .org { font-size: 9px; font-weight: 700; letter-spacing: 0.05em; color: var(--ink-soft); }

.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); margin: 22px 4px 10px; }

.action-tile {
  display: flex; align-items: center; gap: 13px; background: var(--paper);
  border-radius: var(--radius-md); padding: 15px 16px; margin-bottom: 8px;
  box-shadow: var(--shadow-card); border: none; width: 100%; text-align: left; cursor: pointer;
  font-family: var(--font);
}
.action-icon {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center;
}
.action-icon svg { width: 19px; height: 19px; }
.action-body { flex: 1; }
.action-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.action-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 1px; }
.action-chevron { color: var(--ink-soft); flex: none; }

.troubleshoot-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: none; border: none; padding: 14px 4px; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--ink-soft); font-family: var(--font);
}

.offline-banner {
  background: var(--warn-soft); border: 1.5px solid #f3d9ad; border-radius: var(--radius-md);
  padding: 14px 15px; display: flex; gap: 12px; margin-bottom: 16px;
}
.offline-banner svg { flex: none; color: var(--warn); margin-top: 1px; }
.offline-banner-title { font-size: 14px; font-weight: 700; color: var(--warn); }
.offline-banner-body { font-size: 13px; color: #7a4a10; margin-top: 3px; line-height: 1.45; }

.back-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 18px; font-size: 14px;
  font-weight: 600; color: var(--ink-soft); background: none; border: none; cursor: pointer;
  padding: 0; font-family: var(--font);
}

.step-card { display: flex; gap: 14px; margin-bottom: 8px; }
.step-num {
  width: 30px; height: 30px; border-radius: 50%; flex: none; background: var(--ink); color: white;
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center;
}
.step-text { padding-top: 4px; font-size: 15px; line-height: 1.45; }
.step-text b { font-weight: 700; }
.step-connector-v { width: 1.5px; height: 20px; background: var(--line); margin-left: 14.5px; }

.hidden { display: none !important; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: white; padding: 12px 20px; border-radius: 999px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-card); z-index: 100;
}
.toast.error { background: var(--bad); }

footer.page-footer { margin-top: 26px; font-size: 12px; color: var(--ink-soft); opacity: 0.75; text-align: center; }

/* -- top-bar overflow menu (replaces the old bare sign-out-glyph button)
 *
 * A real, labelled dropdown: "..." alone read as a menu but silently
 * signed people out — see menu.js's own module docstring for the full
 * incident. Kept visually close to the old .avatar circle (same size,
 * same position) so the rest of the top bar's layout doesn't shift.
 */
.menu-wrap { position: relative; }
.menu-trigger {
  width: 34px; height: 34px; border-radius: 50%; background: var(--ink);
  color: white; display: flex; align-items: center; justify-content: center;
  cursor: pointer; border: none; padding: 0;
}
.menu-trigger svg { width: 17px; height: 17px; }
.menu-dropdown {
  position: absolute; top: 42px; right: 0; min-width: 200px;
  background: var(--paper); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card); border: 1px solid var(--line);
  padding: 6px; z-index: 50;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer; font-family: var(--font);
  font-size: 14.5px; font-weight: 500; color: var(--ink); padding: 10px 12px;
  border-radius: var(--radius-sm); text-decoration: none;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--paper-sunken); outline: none; }
.menu-item svg { width: 17px; height: 17px; flex: none; color: var(--ink-soft); }
.menu-separator { height: 1px; background: var(--line); margin: 6px 4px; }
.menu-item-danger { color: var(--bad); }
.menu-item-danger svg { color: var(--bad); }

/* -- Badge details section ------------------------------------------- */
.details-list { display: flex; flex-direction: column; gap: 0; }
.details-row {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.details-row:last-child { border-bottom: none; }
.details-row-label { color: var(--ink-soft); flex: none; }
.details-row-value { text-align: right; font-weight: 600; word-break: break-word; }
.setup-help {
  margin-top: 18px; padding: 14px 15px; background: var(--paper-sunken);
  border-radius: var(--radius-md); font-size: 13.5px; line-height: 1.55; color: var(--ink-soft);
}
.setup-help b { color: var(--ink); }


/* -- Logo picker: thumbnail grid, not a name-only <select> ---------------
 *
 * A filename tells you nothing about what an image actually looks like —
 * every tile shows the real (small) thumbnail self_graphics.py returns,
 * so choosing a logo means recognizing it, not decoding a key string.
 * role="radiogroup"/"radio" (see edit.html/edit.js) since this is a
 * single-select control, same semantics as the <select> it replaces.
 */
.graphic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.graphic-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--paper); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); padding: 8px 6px 7px; cursor: pointer;
  font-family: var(--font);
}
.graphic-tile img, .graphic-tile-none {
  width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 6px;
}
.graphic-tile-none {
  display: flex; align-items: center; justify-content: center;
  background: var(--paper-sunken); color: var(--ink-soft); font-size: 12px;
}
.graphic-tile-label {
  font-size: 11px; color: var(--ink-soft); text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.graphic-tile.selected {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.graphic-tile:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
