/* Admin area: the sign-in page and the submissions dashboard.
   Deliberately separate from styles.css — the marketing site and an
   internal tool want different things. */

:root {
  --a-ink: #0b1f33;
  --a-ink-soft: #334155;
  --a-muted: #64748b;
  --a-bg: #e8ebee;
  --a-card: #ffffff;
  --a-line: #dde3e9;
  --a-green: #12b886;
  --a-green-dark: #0ca678;
  --a-danger: #b91c1c;
  /* KarimiConsulting brand, used on the sign-in page. */
  --a-brand: #ff9900;
  --a-brand-dark: #f59e0b;
  --a-navy: #24456d;
  --a-navy-deep: #152942;
  --a-focus: #ffd380;
  --a-radius: 12px;
  --a-shadow: 0 1px 2px rgba(15, 32, 51, 0.06), 0 1px 3px rgba(15, 32, 51, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--a-ink);
  background: var(--a-bg);
  font-family: "Open Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: var(--a-ink);
}

/* ---------- top bar ------------------------------------------------ */

.admin-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 36px);
  background: var(--a-card);
  border-bottom: 1px solid var(--a-line);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.admin-brand img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 10px;
  flex: 0 0 auto;
}

.admin-brand-text {
  min-width: 0;
}

.admin-brand-name {
  display: block;
  font-family: "Poppins", Arial, sans-serif;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.admin-brand-role {
  display: block;
  margin-top: 2px;
  color: var(--a-muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ---------- buttons ------------------------------------------------ */

.a-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--a-line);
  border-radius: 10px;
  background: var(--a-card);
  color: var(--a-ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, transform 120ms ease;
}

.a-btn:hover:not(:disabled) {
  background: #f3f5f7;
}

.a-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.a-btn:focus-visible {
  outline: 3px solid var(--a-focus);
  outline-offset: 2px;
}

.a-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.a-btn.primary {
  border-color: transparent;
  background: var(--a-green);
  color: #06281f;
}

.a-btn.primary:hover:not(:disabled) {
  background: var(--a-green-dark);
}

.a-btn.block {
  width: 100%;
}

.a-btn.link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--a-ink-soft);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- dashboard ---------------------------------------------- */

.admin-main {
  width: min(1180px, 100% - clamp(24px, 6vw, 56px));
  margin: 0 auto;
  padding: clamp(24px, 4vw, 40px) 0 56px;
}

.admin-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.admin-title {
  margin: 0;
  font-family: "Poppins", Arial, sans-serif;
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.12;
}

.admin-subtitle {
  margin: 6px 0 0;
  color: var(--a-muted);
  font-size: 0.95rem;
}

/* Search and Refresh share a row; Download CSV sits beneath them, aligned
   to the left edge of the search field. */
.admin-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  width: min(100%, 400px);
}

.tool-row {
  display: flex;
  gap: 12px;
  width: 100%;
}

.admin-search {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--a-line);
  border-radius: 10px;
  background: var(--a-card);
  color: var(--a-ink);
  font: inherit;
}

.admin-search::placeholder {
  color: #9aa6b2;
}

.admin-search:focus-visible,
.a-field input:focus-visible {
  outline: 3px solid var(--a-focus);
  outline-offset: 1px;
  border-color: #b9c6d2;
}

.a-btn.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.82rem;
}

.a-btn.danger {
  border-color: #f3c2c2;
  background: #fff5f5;
  color: var(--a-danger);
}

.a-btn.danger:hover:not(:disabled) {
  border-color: var(--a-danger);
  background: #fee2e2;
}

.cell-actions {
  white-space: nowrap;
  text-align: right;
}

/* The message column is wide, so the table scrolls sideways. Pin the
   action column to the right edge so Delete is always reachable. */
table.subs th:last-child,
table.subs td:last-child {
  position: sticky;
  right: 0;
  background: var(--a-card);
  box-shadow: -8px 0 12px -8px rgba(15, 32, 51, 0.18);
}

table.subs th:last-child {
  background: #f7f9fb;
  z-index: 2;
}

table.subs tbody tr:hover td:last-child {
  background: #fafbfc;
}

/* Stop the message column forcing the table wider than it needs to be. */
.cell-message {
  max-width: 420px;
}

/* ---------- confirmation dialog ------------------------------------ */

dialog.confirm {
  width: min(440px, calc(100vw - 32px));
  padding: 26px;
  border: 1px solid var(--a-line);
  border-radius: 14px;
  background: var(--a-card);
  color: var(--a-ink);
  box-shadow: 0 30px 70px rgba(5, 16, 30, 0.35);
}

dialog.confirm::backdrop {
  background: rgba(9, 22, 38, 0.55);
}

.confirm-title {
  margin: 0;
  font-family: "Poppins", Arial, sans-serif;
  font-size: 1.22rem;
  font-weight: 800;
}

.confirm-lede {
  margin: 8px 0 18px;
  color: var(--a-muted);
  font-size: 0.92rem;
}

.confirm-record {
  margin: 0 0 20px;
  padding: 14px 16px;
  border: 1px solid var(--a-line);
  border-radius: 10px;
  background: #f7f9fb;
  font-size: 0.9rem;
}

.confirm-record > div {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  padding: 3px 0;
}

.confirm-record dt {
  color: var(--a-muted);
  font-weight: 700;
}

.confirm-record dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

dialog.confirm .a-btn.danger {
  border-color: var(--a-danger);
  background: var(--a-danger);
  color: #fff;
}

dialog.confirm .a-btn.danger:hover:not(:disabled) {
  background: #991b1b;
}

.admin-bar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-back {
  margin: 20px 0 0;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.auth-back a {
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
}

.auth-back a:hover {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.auth-back a:focus-visible {
  outline: 3px solid var(--a-focus);
  outline-offset: 3px;
  border-radius: 4px;
}

.a-fineprint {
  display: inline-block;
  max-width: 34ch;
  color: var(--a-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  padding: 20px 22px;
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
  background: var(--a-card);
  box-shadow: var(--a-shadow);
}

.stat-value {
  font-family: "Poppins", Arial, sans-serif;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
}

.stat-label {
  margin-top: 4px;
  color: var(--a-muted);
  font-size: 0.88rem;
}

.panel {
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
  background: var(--a-card);
  box-shadow: var(--a-shadow);
  overflow: hidden;
}

.panel-empty {
  display: grid;
  place-items: center;
  min-height: 180px;
  padding: 40px 24px;
  color: var(--a-muted);
  text-align: center;
}

.table-scroll {
  overflow-x: auto;
}

table.subs {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

table.subs th,
table.subs td {
  padding: 14px 18px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--a-line);
}

table.subs th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7f9fb;
  color: var(--a-muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

table.subs tbody tr:last-child td {
  border-bottom: 0;
}

table.subs tbody tr:hover {
  background: #fafbfc;
}

.cell-name {
  font-weight: 700;
}

.cell-when {
  color: var(--a-muted);
  white-space: nowrap;
}

.cell-message {
  min-width: 260px;
  color: var(--a-ink-soft);
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  border: 1px solid var(--a-line);
  border-radius: 999px;
  background: #f4f7fa;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

/* ---------- sign-in page ------------------------------------------- */

.auth-wrap {
  display: grid;
  justify-items: center;
  /* "safe" keeps the top of the card reachable when the window is shorter
     than the card; plain centring can push it above the scroll origin. */
  align-content: safe center;
  min-height: 100svh;
  padding: 32px 20px;
  /* The card and the back link stack as one centred column. */
  grid-auto-rows: min-content;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(255, 153, 0, 0.16), transparent 60%),
    linear-gradient(160deg, var(--a-navy) 0%, var(--a-navy-deep) 100%);
}

.auth-card {
  width: min(460px, 100%);
  padding: clamp(26px, 5vw, 38px);
  border: 1px solid var(--a-line);
  border-radius: 16px;
  background: var(--a-card);
  box-shadow: 0 30px 70px rgba(5, 16, 30, 0.35);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.auth-brand img {
  width: 68px;
  height: 68px;
  object-fit: contain;
}

.auth-title {
  margin: 0;
  color: var(--a-ink);
  font-family: "Nova Square", "Poppins", Arial, sans-serif;
  font-size: 1.6rem;
  font-weight: 400;
  letter-spacing: 0;
}

.auth-lede {
  margin: 6px 0 24px;
  color: var(--a-muted);
  font-size: 0.95rem;
}

.a-field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.a-field > span {
  font-size: 0.82rem;
  font-weight: 700;
}

.a-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--a-line);
  border-radius: 10px;
  background: var(--a-card);
  color: var(--a-ink);
  font: inherit;
}

.a-hint {
  margin: -8px 0 16px;
  color: var(--a-muted);
  font-size: 0.8rem;
}

.a-code {
  letter-spacing: 0.4em;
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
}

.a-switch {
  margin: 18px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--a-line);
  color: var(--a-muted);
  font-size: 0.9rem;
  text-align: center;
}

.a-note {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
}

.a-note:empty {
  display: none;
}

.a-note[data-tone="error"] {
  color: #7f1d1d;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.a-note[data-tone="success"] {
  color: #065f46;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
}

.a-note[data-tone="info"] {
  color: #1e3a5f;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

/* The dashboard keeps its green; the sign-in page uses the site's orange. */
.auth-card .a-btn.primary {
  background: var(--a-brand);
  color: #3d2600;
  box-shadow: 0 14px 30px rgba(255, 153, 0, 0.3);
}

.auth-card .a-btn.primary:hover:not(:disabled) {
  background: var(--a-brand-dark);
}

.auth-card .a-btn.link {
  color: var(--a-navy);
}

[hidden] {
  display: none !important;
}

/* ---------- narrow screens ----------------------------------------- */

@media (max-width: 860px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .admin-head {
    flex-direction: column;
  }

  .admin-tools {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .admin-brand img {
    width: 42px;
    height: 42px;
  }

  .admin-brand-name {
    font-size: 1rem;
  }
}
