/* ==========================================================================
   Admin dashboard shell
   ========================================================================== */

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* --- Login --------------------------------------------------------------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.2rem;
  background: linear-gradient(160deg, #101426 0%, #1e1b4b 60%, #312e81 100%);
}
.login-screen .card { width: min(400px, 100%); }
.login-logo { font-size: 2.8rem; text-align: center; }
.login-screen h1 { text-align: center; margin-bottom: .1rem; }

/* --- Layout -------------------------------------------------------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px; flex: none;
  background: #101426; color: #cdd3e4;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.15rem 1.1rem; font-weight: 800; font-size: 1.05rem; color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
}
.sidebar-logo { font-size: 1.4rem; }

.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: .7rem .6rem 1rem; }
.nav-group {
  margin: 1rem .5rem .35rem; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .12em; color: #6b7490; font-weight: 700;
}
.nav-group:first-child { margin-top: .3rem; }
.nav-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; font: inherit; font-size: .9rem; font-weight: 500;
  color: #cdd3e4; padding: .52rem .6rem; border-radius: 8px; cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-item:disabled { opacity: .35; cursor: not-allowed; }

.sidebar-footer { flex: none; padding: .8rem; border-top: 1px solid rgba(255, 255, 255, .09); }
.sidebar-user { margin-bottom: .6rem; }
.sidebar-user-name { font-weight: 600; color: #fff; font-size: .9rem; }
.sidebar-user-role { font-size: .74rem; color: #6b7490; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.sidebar-footer .btn { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); color: #cdd3e4; }
.sidebar-footer .btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.content { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .85rem 1.4rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { margin: 0; font-size: 1.2rem; flex: 1 1 auto; }
.topbar-right { display: flex; align-items: center; gap: .6rem; }
.promotion-picker { width: auto; min-width: 200px; max-width: 320px; font-size: .88rem; padding: .4rem .6rem; }
.menu-toggle { display: none; font-size: 1.2rem; }

.views { padding: 1.4rem; flex: 1 1 auto; }
.view { animation: view-in .18s ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* --- Overview ------------------------------------------------------------ */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 170px; padding-top: .5rem; }
.chart-bar { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-width: 4px; position: relative; }
.chart-bar i { display: block; border-radius: 2px 2px 0 0; background: var(--brand); min-height: 2px; }
.chart-bar i.wins { background: var(--success); }
.chart-bar:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #101426; color: #fff; font-size: .72rem; padding: .3rem .5rem;
  border-radius: 6px; white-space: nowrap; z-index: 5; margin-bottom: 4px;
}
.chart-legend { display: flex; gap: 1rem; font-size: .78rem; color: var(--muted); margin-top: .6rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: .3rem; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.activity-feed { list-style: none; margin: 0; padding: 0; max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: .4rem; }
.activity-item {
  display: flex; gap: .6rem; align-items: baseline;
  padding: .45rem .55rem; border-radius: 8px; background: var(--surface-2); font-size: .86rem;
  animation: view-in .2s ease-out;
}
.activity-item time { color: var(--faint); font-size: .74rem; margin-left: auto; white-space: nowrap; }

/* --- Wheel designer ------------------------------------------------------ */
.wheel-layout { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 1.2rem; align-items: start; }
.preview-card { position: sticky; top: 5rem; }
.preview-stage {
  position: relative; border-radius: var(--radius); padding: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  background: #0b1020; min-height: 340px;
}
/* The pointer, rim lights and shadow are all drawn inside the canvas, so the
   preview needs nothing over the top of it. */
.preview-stage canvas { width: min(100%, 400px); aspect-ratio: 1; display: block; }

.color-field { display: flex; align-items: center; gap: .5rem; }
.color-field input[type=text] { flex: 1; font-family: var(--mono); font-size: .85rem; }

/* --- Logo manager -------------------------------------------------------- */
.logo-list { display: flex; flex-direction: column; gap: .5rem; }
.logo-row, .logo-main {
  display: flex; align-items: center; gap: .7rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .55rem .65rem; background: var(--surface);
}
.logo-thumb {
  flex: none; width: 74px; height: 44px; border-radius: 6px;
  display: grid; place-items: center; overflow: hidden;
  /* Checkerboard so transparent PNGs are obvious */
  background-color: #eef1f7;
  background-image:
    linear-gradient(45deg, #dfe4ee 25%, transparent 25%, transparent 75%, #dfe4ee 75%),
    linear-gradient(45deg, #dfe4ee 25%, transparent 25%, transparent 75%, #dfe4ee 75%);
  background-size: 12px 12px;
  background-position: 0 0, 6px 6px;
}
.logo-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.logo-thumb.is-dark { background-color: #0b1020; background-image: none; }
.logo-row .grow { min-width: 0; }
.logo-row input[type=text] { font-size: .84rem; padding: .32rem .5rem; }
.logo-url { font-size: .72rem; color: var(--faint); word-break: break-all; margin-top: .2rem; }
.logo-actions { display: flex; align-items: center; gap: .15rem; flex: none; }
.logo-actions .btn { padding: .25rem .45rem; font-size: .78rem; }
.logo-main .grow { min-width: 0; }

/* Logo strip inside the wheel preview */
.preview-strip {
  position: absolute; left: 50%; bottom: .8rem; transform: translateX(-50%);
  display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; justify-content: center;
  max-width: calc(100% - 2rem);
  padding: .4rem .7rem; border-radius: 10px;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .14);
}
.preview-strip.at-header { top: .8rem; bottom: auto; }
.preview-strip > span {
  font-size: .6rem; text-transform: uppercase; letter-spacing: .12em;
  color: rgba(255, 255, 255, .55); font-weight: 700; white-space: nowrap;
}
.preview-strip > span:empty { display: none; }
#preview-strip-logos { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
#preview-strip-logos img {
  height: 26px; width: auto; max-width: 90px; object-fit: contain; display: block;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .5));
}
.preview-strip.size-small #preview-strip-logos img { height: 18px; }
.preview-strip.size-large #preview-strip-logos img { height: 38px; }

/* --- Prizes -------------------------------------------------------------- */
.swatch { width: 20px; height: 20px; border-radius: 5px; border: 1px solid var(--border-strong); display: inline-block; flex: none; }
.prob-cell { display: flex; align-items: center; gap: .5rem; min-width: 120px; }
.prob-cell .meter { flex: 1; min-width: 44px; }
.stock-low { color: var(--danger); font-weight: 700; }
.reorder { display: flex; flex-direction: column; gap: 1px; }
.reorder button { line-height: 1; padding: 1px 5px; font-size: .7rem; }

/* --- Screens ------------------------------------------------------------- */
.screen-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem;
  display: flex; gap: .8rem; align-items: center; justify-content: space-between;
}
.screen-url { font-size: .74rem; color: var(--faint); word-break: break-all; }
.join-qr { background: #fff; padding: .8rem; border-radius: var(--radius); display: inline-block; line-height: 0; border: 1px solid var(--border); }
.join-qr img { width: min(230px, 60vw); height: auto; display: block; }

/* --- Reports ------------------------------------------------------------- */
.report-toolbar {
  display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap;
  padding: .85rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}
.report-toolbar .field { margin: 0; }
.report-toolbar input, .report-toolbar select { font-size: .86rem; padding: .4rem .55rem; }
.report-toolbar label { font-size: .72rem; margin-bottom: .2rem; }
.toolbar-search { min-width: 180px; flex: 1 1 200px; }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .7rem 1rem; border-top: 1px solid var(--border); font-size: .85rem; color: var(--muted);
}

/* --- Responsive ---------------------------------------------------------- */
@media (max-width: 1024px) {
  .wheel-layout { grid-template-columns: 1fr; }
  .preview-card { position: static; }
}
@media (max-width: 820px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .views { padding: 1rem .8rem; }
  .topbar { padding: .7rem .9rem; gap: .6rem; }
  .topbar h1 { font-size: 1.05rem; }
  .promotion-picker { min-width: 120px; max-width: 150px; }
}

/* --- Screens: short URL + pairing code ----------------------------------- */
.screen-card { flex-wrap: wrap; align-items: flex-start; }
.screen-no {
  flex: none; min-width: 26px; height: 26px; padding: 0 .4rem;
  border-radius: 8px; background: var(--brand); color: #fff;
  display: inline-grid; place-items: center; font-weight: 800; font-size: .9rem;
}
.screen-type { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; margin: .45rem 0 .3rem; }
.screen-path {
  font-family: var(--mono); font-size: 1rem; font-weight: 700;
  background: var(--brand-soft); color: var(--brand);
  padding: .15rem .5rem; border-radius: 6px;
}
.screen-pair { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: .3rem; }
.pair-code-big {
  font-family: var(--mono); font-size: 1.35rem; font-weight: 800; letter-spacing: .22em;
  background: var(--warn-soft); color: #92400e;
  border: 1px dashed color-mix(in srgb, var(--warn) 45%, transparent);
  padding: .2rem .6rem .2rem .75rem; border-radius: 8px;
}
.pair-instruction {
  text-align: center; font-size: 1.6rem; font-weight: 800; letter-spacing: .04em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .7rem; margin: .3rem 0 1rem;
  user-select: all;
}
.pair-instruction-code { letter-spacing: .3em; color: var(--brand); font-size: 2rem; }

/* --- Promo screen -------------------------------------------------------- */
.promo-video-badge { font-size: 1.1rem; color: var(--accent); }
.logo-row .logo-url .badge { margin-right: .3rem; }

.promo-progress { display: flex; align-items: center; gap: .7rem; margin-top: .8rem; }
.promo-progress .meter { flex: 1; height: 9px; }
.promo-progress .meter > span { transition: width .2s ease; }

.promo-preview {
  position: relative;
  background: #0b1020;
  border-radius: var(--radius);
  aspect-ratio: 16 / 9;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.promo-preview img, .promo-preview video {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.promo-preview-badge {
  position: absolute; right: .6rem; bottom: .6rem;
  display: flex; align-items: center; gap: .4rem;
  padding: .35rem .6rem; border-radius: 9px;
  background: rgba(11, 16, 32, .85);
  border: 1px solid rgba(255, 255, 255, .2);
  color: #fff; font-size: .72rem; font-weight: 700;
}

.promo-status { font-size: .84rem; font-weight: 600; color: var(--faint); }
.promo-status.busy { color: var(--muted); }
.promo-status.ok { color: var(--success); }
.promo-status.error { color: var(--danger); }

.promo-preview-badge img { width: 42px; height: 42px; display: block; border-radius: 4px; background: #fff; padding: 2px; }

/* --- Links & QR codes -------------------------------------------------- */
.link-card {
  display: flex; gap: 1.25rem; align-items: flex-start;
  margin-bottom: 1rem; padding: 1.1rem 1.25rem;
}
.link-body { flex: 1 1 auto; min-width: 0; }
.link-body h3 { margin: 0 0 .15rem; font-size: 1.05rem; }
.link-audience { margin: 0 0 .6rem; font-size: .82rem; font-weight: 600; color: var(--accent); }
.link-url {
  display: block; width: 100%; box-sizing: border-box;
  padding: .5rem .65rem; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: .88rem; word-break: break-all;
}
.link-note { margin: .6rem 0 .8rem; font-size: .88rem; line-height: 1.5; }
.link-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.link-qr { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: .35rem; }
.link-qr img {
  width: 128px; height: 128px; display: block;
  border-radius: var(--radius-sm); background: #fff; padding: 6px;
  border: 1px solid var(--border);
}
.link-qr span { font-size: .74rem; }

/* A phone gets the code under the text, not squeezed beside it. */
@media (max-width: 640px) {
  .link-card { flex-direction: column-reverse; align-items: stretch; }
  .link-qr { align-self: flex-start; }
}

/* --- Winner photos ------------------------------------------------------- */
.nav-badge {
  display: inline-block; min-width: 1.35rem; padding: 0 .35rem;
  margin-left: .35rem; border-radius: 999px;
  background: var(--danger); color: #fff;
  font-size: .7rem; font-weight: 800; line-height: 1.35rem; text-align: center;
}

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem;
}
.tabs { display: flex; gap: .3rem; background: var(--surface-2); padding: .25rem; border-radius: var(--radius-sm); }
.tab {
  border: 0; background: transparent; cursor: pointer;
  padding: .4rem .8rem; border-radius: calc(var(--radius-sm) - 2px);
  font: inherit; font-size: .86rem; font-weight: 600; color: var(--muted);
}
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(15, 23, 42, .08); }

.photo-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }

.photo-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
  display: flex; flex-direction: column;
}
/* Contain, not cover: a moderator has to see the whole photo to judge it. */
.photo-card-image {
  background: #0f172a; line-height: 0;
}
.photo-card-image img {
  width: 100%; height: 220px; object-fit: contain; display: block;
}
.photo-card-body { padding: .8rem .9rem; flex: 1 1 auto; }
.photo-card-name { font-weight: 700; }
.photo-card-meta { font-size: .8rem; color: var(--faint); margin-top: .15rem; }
.photo-card-caption {
  margin: .5rem 0 0; font-size: .9rem; line-height: 1.45;
  overflow-wrap: anywhere;
}
.photo-card-note { margin: .5rem 0 0; font-size: .82rem; color: var(--muted); }
.photo-card-actions {
  display: flex; gap: .5rem; padding: .7rem .9rem;
  border-top: 1px solid var(--border); background: var(--surface-2);
}
.photo-card-actions .btn { flex: 1 1 auto; }
