/* =============================================================================
   User-facing web app — consumes tokens from hpp_theme.css
   ============================================================================= */

/* ---------- Form controls -------------------------------------------------- */
label {
  display: block;
  margin-bottom: var(--sp-4);
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-2);
}

input,
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  margin-top: var(--sp-2);
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

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

/* ---------- Buttons -------------------------------------------------------- */
button,
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: 0.65rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}

button:hover,
.btn-primary:hover { background: var(--brand-hover); }
button:active,
.btn-primary:active { transform: translateY(1px); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.error { color: var(--danger); font-size: var(--fs-md); }

/* ---------- Login page ----------------------------------------------------- */
body.login-page {
  height: 100dvh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background:
    radial-gradient(120% 80% at 100% 0%, var(--surface-2), transparent 60%),
    var(--bg);
}

.login-brand {
  position: relative;
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(150deg, #9a1c44 0%, var(--brand) 42%, var(--brand-deep) 78%, #3d0716 100%);
  padding: clamp(1.5rem, 3.2vw, 2.75rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(1rem, 2.2vw, 1.75rem);
}

/* Halftone / CMYK print dot motif */
.login-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.16) 1.5px, transparent 1.6px);
  background-size: 22px 22px;
  opacity: 0.55;
  mask-image: linear-gradient(160deg, #000 5%, transparent 70%);
}
/* Die-cut corner registration mark (print-shop motif) */
.login-brand::after {
  content: "";
  position: absolute;
  right: clamp(1.5rem, 4vw, 3rem);
  bottom: clamp(1.5rem, 4vw, 3rem);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background:
    linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.35)) center / 100% 1px no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.35)) center / 1px 100% no-repeat;
  border: 1px solid rgba(255, 255, 255, 0.28);
  opacity: 0.6;
}

.login-brand > * { position: relative; z-index: 1; }

.login-brand__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.login-brand__logo {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.01em;
}
.login-brand__logo .mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-weight: 800;
}

/* CMYK ink chips — instantly reads as "print" */
.login-brand__cmyk { display: inline-flex; gap: 5px; }
.login-brand__cmyk .ink {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.login-brand__cmyk .ink--c { background: #22b8cf; }
.login-brand__cmyk .ink--m { background: #e64980; }
.login-brand__cmyk .ink--y { background: #fcc419; }
.login-brand__cmyk .ink--k { background: #1b1215; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35); }

.login-brand__mid { max-width: 34ch; }

.login-brand__headline {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 2.6vw, 2.35rem);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.02em;
  margin: 0 0 0.65rem;
  color: #fff;
}
.login-brand__sub { font-size: 0.9rem; max-width: 32ch; color: rgba(255, 255, 255, 0.86); margin: 0; }

.login-brand__points { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.5rem; }
.login-brand__points li { display: flex; align-items: center; gap: 0.55rem; font-size: 0.85rem; color: rgba(255, 255, 255, 0.92); }
.login-brand__points svg { flex: 0 0 auto; width: 18px; height: 18px; color: #fcc419; }

/* Illustrative "live board" preview — replaces the old blank tile grid */
.login-showcase {
  width: min(360px, 100%);
  padding: 0.85rem 1rem 0.95rem;
  border-radius: var(--r-lg);
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}
.login-showcase__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.7rem;
}
.login-showcase__title { font-family: var(--font-display); font-weight: 700; font-size: 0.85rem; color: #fff; }
.login-showcase__live {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.82);
}
.login-showcase__live i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
  animation: login-pulse 2s ease-out infinite;
}
@keyframes login-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.login-showcase__kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 0.75rem; }
.login-kpi {
  padding: 0.45rem 0.55rem;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.login-kpi__label { display: block; font-size: 0.62rem; letter-spacing: 0.03em; text-transform: uppercase; color: rgba(255, 255, 255, 0.66); }
.login-kpi__value { display: block; margin-top: 0.1rem; font-family: var(--font-display); font-weight: 800; font-size: 1.1rem; color: #fff; font-variant-numeric: tabular-nums; }

.login-showcase__chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 40px;
}
.login-showcase__chart span {
  flex: 1;
  height: var(--h);
  border-radius: 3px 3px 0 0;
  background: rgba(255, 255, 255, 0.30);
}
.login-showcase__chart span.hot { background: #fcc419; }

.login-panel {
  display: grid;
  place-items: center;
  padding: clamp(1.5rem, 4vw, 3rem);
}

.login-card {
  width: min(400px, 100%);
  padding: clamp(1.5rem, 4vw, 2.25rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  animation: hpp-rise var(--dur) var(--ease) both;
}
.login-card__eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.2rem 0.55rem;
  margin-bottom: 0.9rem;
  border-radius: var(--r-full);
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.login-card h1 {
  font-size: var(--fs-2xl);
  margin: 0 0 0.25rem;
}
.login-card .subtitle { color: var(--muted); margin: 0 0 2rem; font-size: var(--fs-md); }

.login-card form { display: block; }

.field { position: relative; display: block; margin-top: var(--sp-2); }
.field input { margin-top: 0; }
.field input[type="password"],
.field input[type="text"].pw { padding-right: 3rem; }

.pw-toggle {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  min-height: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border-radius: var(--r-sm);
}
.pw-toggle:active { transform: translateY(-50%); }
.pw-toggle:hover { background: var(--surface-2); color: var(--text); }
.pw-toggle svg { width: 20px; height: 20px; }

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 0.5rem;
  box-shadow: var(--sh-brand);
}

.btn-spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: hpp-spin 0.7s linear infinite;
}
@keyframes hpp-spin { to { transform: rotate(360deg); } }

.login-card .error {
  margin-top: 1rem;
  padding: 0.7rem 0.9rem;
  background: var(--danger-bg);
  color: var(--danger-fg);
  border: 1px solid #fecaca;
  border-radius: var(--r-md);
}

.login-foot { margin-top: 0; font-size: var(--fs-xs); color: rgba(255, 255, 255, 0.55); }

@media (max-width: 860px) {
  body.login-page {
    grid-template-columns: 1fr;
    /* Let the page grow and scroll on short/landscape phones instead of
       clipping the card when it can't be perfectly centred. */
    height: auto;
    min-height: 100dvh;
    overflow: auto;
    grid-template-rows: auto 1fr;
    align-content: start;
  }
  .login-brand {
    padding: 1.5rem 1.75rem;
    gap: 0;
  }
  .login-brand__mid, .login-showcase, .login-foot { display: none; }
  .login-brand::after { display: none; }
}

@media (max-width: 480px) {
  .login-brand { padding: 1.25rem 1.1rem; }
  .login-panel { padding: 1.75rem 1.1rem; }
}

/* ---------- Error pages ---------------------------------------------------- */
.error-page {
  max-width: 460px;
  margin: 12vh auto;
  padding: var(--sp-6);
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
}

/* ---------- KPI cards & badges (shared dashboard primitives) --------------- */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  padding: var(--sp-4);
}
.kpi-card .label { color: var(--muted); font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-card .value { font-family: var(--font-display); font-size: var(--fs-xl); font-weight: 700; margin-top: 0.35rem; }

.badge-freshness {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--r-full);
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-size: var(--fs-xs);
  font-weight: 600;
}

/* ---------- Responsive dashboard primitives -------------------------------- */
/* Shared classes the dashboard JS renders into, so KPI rows, tables, and
   filter controls reflow on any screen without per-dashboard media queries. */

/* Auto-fitting KPI/metric row: cards shrink toward ~150px, then wrap. */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 42vw, 200px), 1fr));
  gap: clamp(0.6rem, 2vw, 1rem);
}

/* Wrap any wide data table so it scrolls horizontally instead of blowing out
   the page width on mobile (mirrors the admin console's .admin-table-wrap). */
.data-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--sh-sm);
}
.data-table-wrap > table { width: 100%; border-collapse: collapse; min-width: max-content; }
.data-table-wrap th,
.data-table-wrap td { padding: 0.6rem 0.8rem; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }

/* Opt-in filter row: inline + wrapping on desktop, single-column on phones.
   Apply to a wrapper the dashboard JS renders; does not restyle the existing
   .dashboard-filter-panel__body container. */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 0.75rem;
  align-items: flex-end;
}
.filter-row > * { flex: 1 1 180px; min-width: 0; }

@media (max-width: 480px) {
  .filter-row > * { flex-basis: 100%; }
}
