/*
 * Advertising Project — dashboard design system.
 *
 * A plain stylesheet rather than a build step: the dashboard is five pages of
 * CRUD and the blueprint's stack note is explicit about not putting a toolchain
 * between you and a working pairing flow.
 *
 * The class contract (card, pill, row, stat, dim, ghost, danger) is what the
 * views use, so the look can change without touching a single view.
 */

:root {
  --bg:        #f5f6f8;
  --surface:   #ffffff;
  --raised:    #fbfcfd;
  --line:      #e4e7ec;
  --line-soft: #eef1f4;

  --txt:  #101828;
  --txt-2:#475467;
  --dim:  #667085;

  --accent:      #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff4ff;

  --ok:   #067647;  --ok-soft:   #ecfdf3;  --ok-line:   #abefc6;
  --warn: #b54708;  --warn-soft: #fffaeb;  --warn-line: #fedf89;
  --bad:  #b42318;  --bad-soft:  #fef3f2;  --bad-line:  #fecdca;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow:    0 1px 2px rgba(16,24,40,.05);
  --shadow-md: 0 4px 12px -2px rgba(16,24,40,.08), 0 2px 4px -2px rgba(16,24,40,.04);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------- shell */

.shell { display: flex; min-height: 100vh; }

/* ------------------------------------------------------------- sidebar */

.sidebar {
  width: 244px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  /*
   * --banner-h is set from JS when the impersonation banner is present. Without
   * it a 100vh sidebar sitting below a 51px banner overflows by exactly that,
   * pushing its footer (account, sign out) off the bottom of the screen.
   */
  top: var(--banner-h, 0px);
  height: calc(100vh - var(--banner-h, 0px));
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -.01em;
  color: var(--txt);
  text-decoration: none;
  border-bottom: 1px solid var(--line-soft);
}

.brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  flex: none;
}

.side-nav { padding: 12px 10px; flex: 1; }

.side-group {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #98a2b3;
  padding: 14px 10px 6px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--txt-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .13s, color .13s;
}

.side-link:hover { background: var(--line-soft); color: var(--txt); }
.side-link.on    { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }

.side-link svg { width: 17px; height: 17px; flex: none; stroke-width: 1.9; }

/* Submenu: indented, with a rule so the nesting is legible at a glance. */
.side-sub { margin: 2px 0 2px 22px; padding-left: 12px; border-left: 1px solid var(--line); }
.side-sub .side-link { font-size: 13.5px; padding: 6px 10px; }

.side-foot {
  border-top: 1px solid var(--line-soft);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.side-foot .who { min-width: 0; flex: 1; }
.side-foot .who b { display: block; font-size: 13px; font-weight: 600; }
.side-foot .who span { font-size: 11.5px; color: var(--dim); }
.side-foot .who b, .side-foot .who span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------------------------------------------------------- mobile bar */

.topbar { display: none; }

.hamburger {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--txt);
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  line-height: 0;
}

/* Without an explicit size an inline SVG collapses to nothing and the button
   renders as an empty box. */
.hamburger svg { width: 18px; height: 18px; stroke-width: 2; }

.scrim { display: none; }

@media (max-width: 860px) {
  .shell { display: block; }

  .topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 10px 14px;
    position: sticky;
    top: 0;
    z-index: 40;
  }

  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-md);
    height: calc(100dvh - var(--banner-h, 0px));
    top: var(--banner-h, 0px);
  }

  body.nav-open .sidebar { transform: none; }

  body.nav-open .scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(16,24,40,.45);
    z-index: 50;
  }

  /* The drawer scrolls, not the page behind it. */
  body.nav-open { overflow: hidden; }
}

/* ------------------------------------------------------------------ page */

main {
  flex: 1;
  min-width: 0;
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 30px 64px;
  width: 100%;
}

h1 {
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -.02em;
  margin: 0 0 6px;
}

h1 + p.dim { margin: 0 0 22px; font-size: 14px; }

h2 {
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--dim);
  margin: 32px 0 12px;
}

a { color: var(--accent); }

@media (max-width: 860px) {
  main { padding: 20px 16px 48px; }
}

/* ----------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

/* ---------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  color: var(--dim);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  font-size: 14px;
}

tr:last-child td { border-bottom: 0; }
tbody tr:hover td, table tr:hover td { background: var(--raised); }

/* --------------------------------------------------------------- controls */

input, select, textarea {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--txt);
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  box-shadow: var(--shadow);
  transition: border-color .13s, box-shadow .13s;
}

input:hover, select:hover { border-color: #d0d5dd; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

input::placeholder { color: #98a2b3; }
input[type=file] { padding: 6px 9px; box-shadow: none; }
input[type=checkbox] { width: auto; box-shadow: none; accent-color: var(--accent); }
select { cursor: pointer; }

button {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: background .13s, border-color .13s, box-shadow .13s;
  white-space: nowrap;
}
button:hover  { background: var(--accent-dark); border-color: var(--accent-dark); }
button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
button:active { transform: translateY(.5px); }

button.ghost {
  background: var(--surface);
  border-color: var(--line);
  color: var(--txt-2);
}
button.ghost:hover { background: var(--raised); border-color: #d0d5dd; color: var(--txt); }

button.danger {
  background: var(--surface);
  border-color: var(--bad-line);
  color: var(--bad);
}
button.danger:hover { background: var(--bad-soft); }

button:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------------------------------------------------------- layout */

.row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }

/* ----------------------------------------------------------------- pills */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 550;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--raised);
  color: var(--txt-2);
  white-space: nowrap;
  vertical-align: middle;
}

.pill::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: .75;
}

.pill.on   { color: var(--ok);   background: var(--ok-soft);   border-color: var(--ok-line); }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: var(--warn-line); }
.pill.bad  { color: var(--bad);  background: var(--bad-soft);  border-color: var(--bad-line); }
.pill.off  { color: var(--dim); }

/* ----------------------------------------------------------------- stats */

.stat { display: inline-block; margin-right: 42px; }
.stat:last-child { margin-right: 0; }

.stat b {
  display: block;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.15;
}

.stat span {
  color: var(--dim);
  font-size: 12px;
  font-weight: 550;
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* --------------------------------------------------------------- notices */

.flash, .err {
  padding: 12px 15px;
  border-radius: var(--radius);
  margin-bottom: 18px;
  font-size: 14px;
  border: 1px solid;
  display: flex;
  gap: 9px;
  align-items: flex-start;
}

.flash { background: var(--ok-soft);  border-color: var(--ok-line);  color: var(--ok); }
.err   { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }

.flash::before { content: "✓"; font-weight: 700; }
.err::before   { content: "!"; font-weight: 700; }

/* ------------------------------------------------------------------ icons */

/*
 * A floor for every inline icon. The partial also sets width/height attributes;
 * this catches any context that tries to stretch one and keeps a missing rule
 * from becoming a full-page glyph again.
 */
svg[viewBox="0 0 24 24"] { max-width: 100%; max-height: 2.5em; }

/* ---------------------------------------------------------- icon buttons */

/*
 * Row actions are icons, not a wall of labelled buttons. Every one carries a
 * title and an aria-label, so the meaning is available on hover and to a screen
 * reader rather than only to someone who recognises the glyph.
 */
.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--dim);
  box-shadow: none;
  cursor: pointer;
  transition: background .13s, color .13s, border-color .13s;
}

.iconbtn:hover { background: var(--line-soft); color: var(--txt); border-color: var(--line); }
.iconbtn svg   { width: 16px; height: 16px; stroke-width: 1.9; }

.iconbtn.danger { background: transparent; border-color: transparent; color: var(--dim); }
.iconbtn.danger:hover { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.iconbtn.go:hover     { background: var(--accent-soft); color: var(--accent-dark); border-color: #c7d7fe; }

.iconbtn:disabled { opacity: .3; cursor: not-allowed; }
.iconbtn:disabled:hover { background: transparent; border-color: transparent; color: var(--dim); }

/* ----------------------------------------------------------- media picker */

.picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--raised);
}

.picker-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--surface);
  font-weight: 400;
  min-width: 0;
}

.picker-item:hover { border-color: var(--line); }
.picker-item:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.picker-item input { flex: none; }

/* --------------------------------------------------------- now playing */

.now-playing {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--txt-2);
}

.now-playing .bar {
  width: 62px; height: 4px;
  border-radius: 3px;
  background: var(--line);
  overflow: hidden;
  flex: none;
}

.now-playing .bar span { display: block; height: 100%; background: var(--ok); }

/* --------------------------------------------------- impersonation banner */

.impersonating {
  background: #fffaeb;
  border-bottom: 1px solid var(--warn-line);
  color: var(--warn);
  padding: 9px 18px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 45;
}

.impersonating svg  { width: 17px; height: 17px; flex: none; }
.impersonating form { margin-left: auto; }
.impersonating button { padding: 5px 12px; font-size: 13px; }

/* ------------------------------------------------------------ table bits */

/* Buttons inside a table row: compact, and they must not wrap into a stack. */
td .row, .actions { flex-wrap: nowrap; justify-content: flex-end; }

td button, td input, td select {
  padding: 6px 11px;
  font-size: 13px;
}

td form { display: inline-flex; }

/* Media thumbnail, and the placeholder when there is no poster yet. */
.thumb {
  width: 76px; height: 46px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--line-soft);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #98a2b3;
  font-size: 15px;
}

/* An error under a status pill needs room to read, not a 90px column. */
.cell-error {
  color: var(--bad);
  font-size: 12px;
  margin-top: 4px;
  max-width: 260px;
  line-height: 1.4;
}

/* ----------------------------------------------------------------- misc */

.dim { color: var(--dim); }

code {
  background: var(--line-soft);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

img { max-width: 100%; }

/* Tables are the one thing that will not fit a phone; let them scroll rather
   than break the whole page layout. */
.card { overflow-x: auto; }

@media (max-width: 640px) {
  .stat { margin-right: 26px; }
  h1    { font-size: 21px; }

  /* A fixed-width control set for a desktop column will otherwise push past the
     card edge on a phone. */
  input, select, textarea { max-width: 100%; }
  .row > form, .row > input, .row > select { max-width: 100%; }
  .card > form .row > * { flex: 1 1 auto; min-width: 0; }
}

/* ------------------------------------------------------------- auth pages */

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 17px;
  letter-spacing: -.01em;
  margin-bottom: 4px;
}

.auth-brand::before {
  content: "";
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
}

.auth-card label {
  display: block;
  font-size: 13px;
  font-weight: 550;
  margin: 16px 0 6px;
  color: var(--txt-2);
}

.auth-card input[type=text],
.auth-card input[type=email],
.auth-card input[type=password] { width: 100%; }

.auth-card button { width: 100%; margin-top: 22px; padding: 10px; }

.auth-error {
  background: var(--bad-soft);
  border: 1px solid var(--bad-line);
  color: var(--bad);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 13px;
  margin-top: 16px;
}

.auth-foot { margin-top: 20px; font-size: 13px; color: var(--dim); text-align: center; }
