/* ==========================================================================
   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;
}
.preview-stage canvas { width: min(100%, 380px); aspect-ratio: 1; }
.preview-pointer {
  position: absolute; top: .55rem; left: 50%; transform: translateX(-50%); z-index: 3;
  width: 0; height: 0;
  border-left: 13px solid transparent; border-right: 13px solid transparent;
  border-top: 26px solid #f8fafc;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .5));
}

.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; }
