/* ============================================================
   Amigo Secreto — Admin dashboard
   Sober Huawei-branded utility UI
   ============================================================ */

:root {
  --bg: #f4f5f6;
  --card: #ffffff;
  --text: #232527;
  --muted: #6b7280;
  --muted-2: #9aa1a9;
  --red: #C7000B;
  --red-dark: #a30009;
  --red-soft: #fdecec;
  --border: #e6e8ea;
  --border-strong: #d6d9dd;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 28px rgba(16, 24, 40, .06);
  --radius: 12px;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Liberation Mono', monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

.mono { font-family: var(--mono); }

/* ── Brand logo (single anniversary banner image) ─────────── */
.brand-logo { display: block; width: auto; height: auto; }
.header-logo { height: 40px; }
.login-logo { height: 52px; }
.boot-logo { height: 52px; }

/* ── Boot state ───────────────────────────────────────────── */
.boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.boot-brand { opacity: .55; animation: bootPulse 1.4s ease-in-out infinite; }
@keyframes bootPulse {
  0%, 100% { opacity: .35; }
  50%      { opacity: .8; }
}

/* ── Login view ───────────────────────────────────────────── */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 5vw, 48px);
  background:
    radial-gradient(1100px 420px at 50% -12%, #ffffff 0%, rgba(255, 255, 255, 0) 62%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 404px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: clamp(28px, 5vw, 40px);
  animation: cardIn .55s cubic-bezier(.21, .7, .25, 1) both;
}
.login-brand { display: flex; justify-content: center; margin-bottom: 26px; }
.login-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.01em;
  text-align: center;
}
.login-subtitle {
  margin: 8px 0 26px;
  font-size: 14px;
  color: var(--muted);
  text-align: center;
}
.login-form { display: block; }
.login-form .input { margin-bottom: 14px; }
.login-form .inline-error { margin: -6px 0 14px; }

/* ── Fields ───────────────────────────────────────────────── */
.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.field-label .optional { color: var(--muted-2); font-weight: 600; }

.input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.3;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.input::placeholder { color: var(--muted-2); }
.input:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(199, 0, 11, .12);
}
.input:disabled {
  background: #f7f8f9;
  color: var(--muted);
  cursor: not-allowed;
}
.input.mono { font-family: var(--mono); font-size: 13.5px; letter-spacing: .02em; }

.inline-error {
  margin: 6px 0 0;
  color: var(--red);
  font-size: 13px;
  font-weight: 600;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease,
              box-shadow .18s ease, transform .06s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; transform: none; }
.btn.is-busy { cursor: progress; opacity: .88; }

.btn-primary {
  background: var(--red);
  color: #fff;
  box-shadow: 0 1px 2px rgba(199, 0, 11, .28);
}
.btn-primary:hover:not(:disabled) {
  background: var(--red-dark);
  box-shadow: 0 6px 18px rgba(199, 0, 11, .28);
}

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--muted-2);
  background: #fafbfb;
}

.btn-outline-red {
  background: #fff;
  color: var(--red);
  border-color: rgba(199, 0, 11, .32);
}
.btn-outline-red:hover:not(:disabled) {
  background: var(--red-soft);
  border-color: var(--red);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: #f1f2f3;
}

.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.btn-hero {
  width: 100%;
  margin-top: 16px;
  padding: 15px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .1em;
}

/* ── App header bar ───────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px clamp(16px, 4vw, 40px);
  background: #fff;
  border-top: 3px solid var(--red);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(16, 24, 40, .03);
}
/* (logo size set via .header-logo) */

/* ── Layout container ─────────────────────────────────────── */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(20px, 3.5vw, 40px) clamp(16px, 4vw, 40px) 72px;
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2.2vw, 24px);
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(18px, 2.4vw, 26px);
  opacity: 0;
  animation: cardIn .55s cubic-bezier(.21, .7, .25, 1) both;
}
#participants-card { animation-delay: .04s; }
#draw-card { animation-delay: .13s; }
#results-card { animation-delay: .2s; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.card-desc {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--muted);
  max-width: 60ch;
}
.count-badge {
  flex: none;
  min-width: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

/* ── Lock banner ──────────────────────────────────────────── */
.lock-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid rgba(199, 0, 11, .22);
  border-left: 3px solid var(--red);
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 14px;
  font-weight: 700;
  animation: bannerIn .4s ease both;
}
.lock-icon { flex: none; }
.lock-text { flex: 1 1 auto; min-width: 180px; }
.lock-banner .btn { margin-left: auto; flex: none; }
@keyframes bannerIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Add participant form ─────────────────────────────────── */
.add-form {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.1fr) minmax(0, 0.8fr) auto;
  gap: 12px;
  align-items: start;
  margin: 18px 0 8px;
}
.add-submit { margin-top: 25px; }

.norm-preview {
  margin: 7px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .01em;
  word-break: break-word;
}

/* ── Data tables ──────────────────────────────────────────── */
.table-wrap { margin-top: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid #f0f1f2;
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .15s ease; }
.data-table tbody tr:hover { background: #fafbfc; }

.cell-name { font-weight: 700; }
.cell-norm { font-family: var(--mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.cell-email { color: var(--muted); word-break: break-word; }
.cell-employee { color: var(--muted); white-space: nowrap; }
.col-action { width: 1%; white-space: nowrap; text-align: right; }

.code-chip {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: .08em;
  color: var(--text);
  background: #f2f3f4;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 9px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.code-chip:hover {
  background: #fff;
  border-color: rgba(199, 0, 11, .4);
  color: var(--red);
}

.btn-remove {
  background: none;
  border: 0;
  padding: 4px 7px;
  border-radius: 6px;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.btn-remove:hover:not(:disabled) { color: var(--red); background: var(--red-soft); }
.btn-remove:disabled { opacity: .4; cursor: not-allowed; }

/* square icon chip buttons (envelope / pencil) next to remover */
.btn-email,
.btn-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  margin-right: 6px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  vertical-align: middle;
  transition: color .15s ease, background .15s ease,
              border-color .15s ease, box-shadow .15s ease, transform .06s ease;
}
.btn-email svg,
.btn-edit svg { display: block; }
.btn-email:hover:not(:disabled),
.btn-edit:hover:not(:disabled) {
  color: var(--red);
  background: var(--red-soft);
  border-color: rgba(199, 0, 11, .4);
}
.btn-email:active:not(:disabled),
.btn-edit:active:not(:disabled) { transform: translateY(1px); }
.btn-email:focus-visible,
.btn-edit:focus-visible {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(199, 0, 11, .14);
}
.btn-email:disabled,
.btn-edit:disabled {
  opacity: .4;
  cursor: not-allowed;
  background: #f7f8f9;
}

/* ── Edit participant modal ───────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 40px);
  background: rgba(16, 24, 40, .45);
  animation: modalFade .18s ease both;
}
.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(16, 24, 40, .28);
  padding: clamp(22px, 3vw, 30px);
  animation: modalIn .32s cubic-bezier(.21, .7, .25, 1) both;
}
.modal-title {
  margin: 0 0 18px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.edit-form { display: block; }
.edit-field { margin-bottom: 16px; }
.edit-field:last-of-type { margin-bottom: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
@keyframes modalFade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* row flash on copy */
.row-flash td { animation: rowFlash .9s ease; }
@keyframes rowFlash {
  0%   { background: rgba(199, 0, 11, .14); }
  100% { background: transparent; }
}

.empty-state {
  margin: 0;
  padding: 26px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ── Sorteio ──────────────────────────────────────────────── */
.seed-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-top: 18px;
}
.seed-field { flex: 1 1 auto; min-width: 0; }

.fingerprint {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: #fbfbfc;
}
.fingerprint-label {
  display: block;
  margin-bottom: 8px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
}
.fingerprint-row { display: flex; align-items: center; gap: 10px; }
.fingerprint-value {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 12.5px;
  color: var(--text);
  word-break: break-all;
}

/* ── Results ──────────────────────────────────────────────── */
.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 16px;
}
.results-table td.giver,
.results-table td.receiver { font-weight: 700; }
.results-table .col-arrow {
  width: 1%;
  padding-left: 8px;
  padding-right: 8px;
}
.arrow-glyph { color: var(--red); font-weight: 800; font-size: 16px; }

/* Masked results — blurred by default until the organizer reveals them */
.results-view { position: relative; }
.results-view .table-wrap { transition: filter .25s ease; }
.results-view.is-masked .table-wrap {
  filter: blur(7px);
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}
.results-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
  background: rgba(255, 255, 255, .45);
  border-radius: 10px;
}
.results-view:not(.is-masked) .results-overlay { display: none; }
.results-overlay .overlay-icon { color: var(--muted); }
.results-overlay-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}
.results-overlay-hint {
  font-size: 13px;
  color: var(--muted);
}

.verify-result {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
}
.verify-result.verifying {
  background: #f4f5f6;
  color: var(--muted);
  border: 1px solid var(--border);
}
.verify-result.ok {
  background: #ecfdf3;
  color: #067647;
  border: 1px solid #abefc6;
}
.verify-result.fail {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid #f5c2c0;
}

/* ── Toasts ───────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  min-width: 200px;
  max-width: 320px;
  padding: 12px 16px;
  border-radius: 10px;
  border-left: 3px solid var(--red);
  background: #232527;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(16, 24, 40, .22);
  transform: translateX(130%);
  opacity: 0;
  transition: transform .32s cubic-bezier(.2, .8, .25, 1), opacity .32s ease;
}
.toast.toast-visible { transform: translateX(0); opacity: 1; }
.toast.toast-leaving { transform: translateX(130%); opacity: 0; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 720px) {
  .add-form { grid-template-columns: 1fr; }
  .add-submit { margin-top: 0; width: 100%; }
  .seed-row { flex-direction: column; align-items: stretch; }
  .seed-row .btn { width: 100%; }
  .results-actions .btn { flex: 1 1 auto; }
  .header-logo { height: 34px; }
  .login-logo { height: 46px; }
  .boot-logo { height: 46px; }
  .fingerprint-row { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ── Print: show only the results table ───────────────────── */
@media print {
  body { background: #fff; }
  .app-header,
  .lock-banner,
  #participants-card,
  #draw-card,
  .results-actions,
  #verify-result,
  #toast-container,
  .no-print { display: none !important; }

  #results-card {
    display: block !important;
    opacity: 1 !important;
    animation: none !important;
    border: none;
    box-shadow: none;
    padding: 0;
  }
  #results-card .card-desc { display: none; }
  .container { max-width: none; padding: 0; display: block; }
  .results-overlay { display: none !important; }
  .table-wrap { overflow: visible; }
  .data-table th,
  .data-table td { border-color: #cfcfcf; }
  .data-table tbody tr:hover { background: transparent; }
}
