/* ViVote — minimalny styl logowania (iteracja 1) */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f4f6fa;
  color: #1a1a1a;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: #001f3f;
  color: #fff;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(0,0,0,0.12);
}
.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  display: inline-flex;
  align-items: center;
}
/* Imię delegata — przepychane na prawo na desktopie (między ViVote a user-info) */
.topbar > .user-name {
  margin-left: auto;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
}

main {
  flex: 1;
  padding: 2rem 1rem;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.card {
  background: #fff;
  border-radius: 0.75rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  padding: 2rem;
  max-width: 28rem;
  width: 100%;
}
.card h2 {
  margin: 0 0 1rem;
  color: #001f3f;
  font-size: 1.5rem;
}
.card p { line-height: 1.5; margin: 0 0 1rem; }
.hint { font-size: 0.875rem; color: #666; margin-top: 1.5rem; }

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #001f3f;
}
/* Pola logowania (tel/email) w karcie — duże, wycentrowane, identyczne dla obu metod. */
.card input[type="tel"],
.card input[type="email"] {
  width: 100%;
  padding: 0.75rem;
  font-size: 1.25rem;
  border: 2px solid #001f3f;
  border-radius: 0.5rem;
  text-align: center;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
  box-sizing: border-box;
}
.card input[type="tel"]:focus,
.card input[type="email"]:focus { outline: none; border-color: #28a745; }

.otp-inputs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin: 1rem 0;
}
.otp-inputs input {
  width: 2.5rem;
  height: 3rem;
  font-size: 1.5rem;
  text-align: center;
  border: 2px solid #001f3f;
  border-radius: 0.5rem;
  font-weight: 700;
  color: #001f3f;
}
.otp-inputs input:focus {
  outline: none;
  border-color: #28a745;
  background: #f0fff4;
}

button.primary,
button.secondary,
button.link-btn {
  font: inherit;
  cursor: pointer;
  border-radius: 0.5rem;
  border: none;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  transition: background 0.15s;
}
button.primary {
  background: #28a745;
  color: #fff;
  width: 100%;
}
button.primary:hover:not(:disabled) { background: #218838; }
button.primary:disabled            { background: #94c79e; cursor: not-allowed; }

button.secondary {
  background: #e5e7eb;
  color: #001f3f;
}
button.secondary:hover { background: #d4d7dd; }

button.link-btn {
  background: none;
  color: #001f3f;
  text-decoration: underline;
  padding: 0.25rem 0.5rem;
}
button.link-btn:disabled {
  color: #888;
  cursor: not-allowed;
  text-decoration: none;
}
button.link-btn:hover:not(:disabled) { color: #28a745; }

.row { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.row > button { flex: 1; }
.center { text-align: center; margin-top: 1rem; }

.error {
  margin: 0.5rem 0;
  padding: 0.75rem;
  background: #ffe6e6;
  border-left: 3px solid #dc3545;
  border-radius: 0.25rem;
  color: #721c24;
  font-size: 0.95rem;
}

#codeTimer { font-weight: 700; color: #001f3f; }

.dashboard-row {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #eee;
  padding: 0.5rem 0;
  margin: 0;
}
.dashboard-row span { color: #666; }
.dashboard-row strong { color: #001f3f; }

.footerbar {
  position: sticky;
  bottom: 0;
  z-index: 50;
  background: #001f3f;
  color: #c7d1e3;
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  box-shadow: 0 -1px 0 rgba(0,0,0,0.15);
}
.footerbar small { color: #c7d1e3; }

/* ====== Top-bar: user info po zalogowaniu ====== */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
}
.user-name {
  font-weight: 700;
}
.user-meta {
  opacity: 0.8;
  font-size: 0.9rem;
}
.user-info .link-btn {
  color: #fff;
  text-decoration: underline;
  padding: 0.25rem 0.5rem;
}
.user-info .link-btn:hover { color: #ffe; }

@media (max-width: 540px) {
  /* Topbar: grid 2 kolumny × 2 rzędy
     Row 1:  ViVote        | Imię (po prawej)
     Row 2:  klub · mandat · badge · Wyloguj  (cała szerokość) */
  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 0.4rem 0.8rem;
    padding: 0.6rem 0.85rem;
  }
  .topbar h1 {
    grid-column: 1; grid-row: 1;
    font-size: 1.05rem;
  }
  .topbar > .user-name {
    grid-column: 2; grid-row: 1;
    margin: 0;                /* reset margin-left:auto z desktopa */
    text-align: right;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
  }
  .user-info {
    grid-column: 1 / -1; grid-row: 2;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.6rem;
  }
  .user-meta { font-size: 0.8rem; }

  /* Wyloguj na końcu wiersza */
  .user-info .link-btn {
    margin-left: auto;
    padding: 0.2rem 0.4rem;
  }

  /* Mniejszy badge "obecny" / "oczekuje", żeby się nie rozjeżdżał */
  .attendance-badge {
    font-size: 0.75rem;
    padding: 0.18rem 0.45rem;
  }

  main { padding: 1rem 0.75rem; }
  .card { padding: 1.25rem; }
  .agenda-card h2 { font-size: 1.5rem; }
  .agenda-list li { padding: 0.6rem 0; gap: 0.5rem; }
}

/* ====== Porządek obrad ====== */
.agenda-card { max-width: 42rem; }
.agenda-card h2 { margin-bottom: 1rem; }

.agenda-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: none;
}
.agenda-list li {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #eef0f4;
  line-height: 1.45;
}
.agenda-list li:last-child { border-bottom: none; }
.agenda-num {
  flex: 0 0 2.25rem;
  font-weight: 700;
  color: #001f3f;
  text-align: right;
}
.agenda-desc {
  flex: 1;
  color: #1a1a1a;
}

.muted {
  color: #888;
  font-style: italic;
}

/* ====== Aktualny punkt obrad (widok delegata) ====== */
.agenda-list li.is-current {
  background: #fff9e6;
  border-radius: 0.375rem;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  margin: 0 -0.75rem;
}
.agenda-badge {
  flex: 0 0 auto;
  align-self: center;
  background: #ffd54f;
  color: #5a3d00;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  border-radius: 0.25rem;
  white-space: nowrap;
  margin-left: auto;
}

/* ====== Wskaźnik połączenia WS ====== */
.ws-status {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  margin-right: 0.6rem;
  vertical-align: middle;
  background: #888;
  transition: background 0.25s;
}
.ws-status[data-state="online"]     { background: #28a745; box-shadow: 0 0 6px rgba(40,167,69,0.6); }
.ws-status[data-state="connecting"] { background: #ffc107; }
.ws-status[data-state="offline"]    { background: #dc3545; }

/* ====== Badge statusu obecności (topbar delegata) ====== */
.attendance-badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.attendance-badge.present { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.attendance-badge.absent  { background: #f8d7da; color: #721c24; border: 1px solid #f1c2c2; }
.attendance-badge.onboard { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }
/* legacy aliases (jeśli gdzieś w cachowanej wersji jeszcze są stare klasy) */
.attendance-badge.confirmed   { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.attendance-badge.pending     { background: #f8d7da; color: #721c24; border: 1px solid #f1c2c2; }
.attendance-badge.needs_teams { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }

/* Wspólny styling dla pól logowania (tel/email) i pomocniczych (teams_name).
   .voting-field ma własne reguły w admin.css i wygrywa wyżej w kaskadzie. */
.card input[type="text"],
.card input[type="email"] {
  width: 100%;
  padding: 0.7rem 0.75rem;
  font-size: 1rem;
  border: 2px solid #001f3f;
  border-radius: 0.5rem;
  box-sizing: border-box;
  margin-bottom: 1rem;
}
.card input[type="text"]:focus,
.card input[type="email"]:focus { outline: none; border-color: #28a745; }

/* ====== Widok głosowania delegata ====== */
.voting-card { max-width: 32rem; }
.voting-card h2 {
  font-size: 1.5rem;
  color: #001f3f;
  margin: 0 0 0.5rem;
}
.voting-desc {
  background: #f4f6fa;
  border-left: 3px solid #001f3f;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  font-size: 0.95rem;
  white-space: pre-wrap;
}

.vote-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 1.5rem;
}
.vote-btn {
  font: inherit;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  padding: 1rem 1.25rem;
  border-radius: 0.6rem;
  border: 3px solid transparent;
  transition: transform 0.05s, box-shadow 0.12s, background 0.12s;
}
.vote-btn:hover:not(:disabled)   { transform: translateY(-1px); }
.vote-btn:active:not(:disabled)  { transform: translateY(0); }
.vote-btn:disabled               { opacity: 0.5; cursor: wait; }

.vote-yes     { background: #28a745; color: #fff; border-color: #1e7d35; }
.vote-yes:hover:not(:disabled)     { background: #218838; }
.vote-no      { background: #dc3545; color: #fff; border-color: #a71d2a; }
.vote-no:hover:not(:disabled)      { background: #c82333; }
.vote-abstain { background: #ffc107; color: #5a3d00; border-color: #d39e00; }
.vote-abstain:hover:not(:disabled) { background: #e0a800; }

/* Po oddaniu głosu */
.voting-done .vote-done-msg {
  text-align: center;
  color: #555;
  margin: 1.5rem 0 0.5rem;
}
.voting-done .vote-done-choice {
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  padding: 1rem;
  border-radius: 0.6rem;
  margin: 0.5rem 0 1.5rem;
  letter-spacing: 0.06em;
}
.vote-done-choice.choice-yes     { background: #d4edda; color: #155724; }
.vote-done-choice.choice-no      { background: #f8d7da; color: #721c24; }
.vote-done-choice.choice-abstain { background: #fff3cd; color: #856404; }

.voting-blocked .error {
  margin-top: 1.5rem;
}

/* ====== Widok wyników głosowania ====== */
.voting-results { max-width: 36rem; }
.voting-results h2 {
  margin: 0 0 0.25rem;
}

.results-conclusion {
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.85rem 1rem;
  border-radius: 0.5rem;
  margin: 1rem 0 1.5rem;
}
.results-conclusion.conclusion-passed   { background: #d4edda; color: #155724; border: 2px solid #28a745; }
.results-conclusion.conclusion-rejected { background: #f8d7da; color: #721c24; border: 2px solid #dc3545; }
.results-conclusion.conclusion-tie      { background: #fff3cd; color: #856404; border: 2px solid #ffc107; }

.results-bars {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin: 1rem 0 1.25rem;
}
.results-bar {
  display: grid;
  grid-template-columns: 1fr 4rem;
  gap: 0.25rem 0.5rem;
  align-items: center;
}
.bar-label {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
}
.bar-label strong { letter-spacing: 0.04em; }
.bar-count { color: #555; font-size: 0.85rem; }
.bar-track {
  grid-column: 1 / 2;
  background: #eef0f4;
  border-radius: 0.3rem;
  height: 1.4rem;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  transition: width 0.35s ease;
  border-radius: 0.3rem;
}
.bar-pct {
  grid-column: 2 / 3;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.bar-yes     .bar-fill { background: #28a745; }
.bar-no      .bar-fill { background: #dc3545; }
.bar-abstain .bar-fill { background: #ffc107; }
.bar-yes     strong { color: #155724; }
.bar-no      strong { color: #721c24; }
.bar-abstain strong { color: #856404; }

.results-summary {
  font-size: 0.92rem;
  color: #444;
  text-align: center;
  padding-top: 0.75rem;
  border-top: 1px solid #eef0f4;
}
.results-summary strong { color: #001f3f; }

.results-my-vote {
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.95rem;
}
.results-my-vote .choice-yes     { color: #155724; }
.results-my-vote .choice-no      { color: #721c24; }
.results-my-vote .choice-abstain { color: #856404; }

/* ====== Election: lista checkboxów ====== */
.election-instruction {
  background: #f4f6fa;
  padding: 0.75rem 1rem;
  border-left: 3px solid #001f3f;
  border-radius: 0 0.4rem 0.4rem 0;
  margin: 1rem 0;
}
.election-options {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.election-options li label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  border: 2px solid #e1e5ee;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 500;
  color: #1a1a1a;
  font-size: 1rem;
  transition: border-color 0.12s, background 0.12s;
}
.election-options li label:hover { background: #f8fafd; }
.election-options li label:has(input:checked) {
  border-color: #28a745;
  background: #f0fff4;
  font-weight: 600;
}
.election-options li label:has(input:disabled) {
  opacity: 0.45;
  cursor: not-allowed;
}
.election-options input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: #28a745;
  flex-shrink: 0;
}

.election-summary {
  text-align: center;
  font-size: 0.95rem;
  margin: 0.75rem 0 0.25rem;
}
.election-summary.over { color: #dc3545; font-weight: 700; }

.secret-notice {
  background: #fff3cd;
  border: 1px solid #ffeaa7;
  color: #856404;
  padding: 0.55rem 0.85rem;
  border-radius: 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
}

/* "Twój głos" jako lista (election) */
.vote-done-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.vote-done-list li {
  background: #f0fff4;
  border: 1px solid #c3e6cb;
  padding: 0.6rem 0.85rem;
  border-radius: 0.4rem;
  color: #155724;
  font-weight: 600;
  text-align: center;
}

/* Election bars — kandydaci "z mandatami" wyróżnieni */
.results-bar.bar-top .bar-fill   { background: #28a745; }
.results-bar.bar-top strong      { color: #155724; }
.results-bar.bar-other .bar-fill { background: #adb5bd; }
.results-bar.bar-other strong    { color: #555; }
.results-bar.bar-other .bar-pct  { color: #555; }

/* HTML atrybut [hidden] musi działać niezależnie od display:flex na klasach.
   Bez tego elementy z `hidden` są widoczne, gdy nadpisujesz im display. */
[hidden] { display: none !important; }
