/* ============================================================
   Abstimmungstool – Global Stylesheet
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #1a1a2e;
  background: #f4f6f9;
  min-height: 100vh;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #1a1a2e;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #1a1a2e;
}

a {
  color: #2563eb;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- Container ---------- */
.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.container.admin {
  max-width: 900px;
}

/* ---------- Subtitle / Helper text ---------- */
.subtitle {
  color: #6b7280;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}

/* ---------- Error ---------- */
.error {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* ---------- Forms ---------- */
form {
  width: 100%;
}

input[type="text"],
input[type="password"] {
  display: block;
  width: 100%;
  padding: 0.65rem 0.875rem;
  font-size: 1rem;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  background: #fff;
  color: #1a1a2e;
  transition: border-color 0.15s;
  margin-bottom: 0.875rem;
}

input[type="text"]:focus,
input[type="password"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* ---------- Buttons ---------- */
.btn,
button[type="submit"],
button[type="button"] {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, box-shadow 0.15s;
  text-decoration: none;
  line-height: 1.4;
}

button[type="submit"],
button[type="button"] {
  background: #2563eb;
  color: #fff;
  margin-top: 1.25rem;
  width: 100%;
}

button[type="submit"]:hover:not(:disabled),
button[type="button"]:hover {
  background: #1d4ed8;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

button[type="submit"]:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: #2563eb;
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
  color: #fff;
}

.btn-secondary {
  background: #f3f4f6;
  color: #374151;
  border: 1.5px solid #d1d5db;
}

.btn-secondary:hover {
  background: #e5e7eb;
  color: #374151;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
}

.btn-danger:hover {
  background: #b91c1c;
  color: #fff;
  box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3);
}

/* ---------- Vote Counter (sticky top) ---------- */
.vote-counter {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #2563eb;
  color: #fff;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}

/* ---------- Vote Table ---------- */
.vote-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  margin-bottom: 1.5rem;
}

.vote-table thead th {
  background: #f1f5f9;
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid #e5e7eb;
}

.vote-row {
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.1s;
}

.vote-row:last-child {
  border-bottom: none;
}

.vote-row:hover {
  background: #f8faff;
}

.vote-row.selected {
  background: #eff6ff;
}

.vote-row td {
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
}

.vote-check {
  text-align: center;
  width: 2.5rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #2563eb;
}

/* ---------- Cards Grid ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 600px) {
  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Card ---------- */
.card {
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 1rem 0.875rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.1s;
  user-select: none;
}

.card:hover {
  border-color: #93c5fd;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}

.card.selected {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.2);
}

.card .presenter {
  font-size: 0.82rem;
  color: #6b7280;
  margin-top: 0.2rem;
}

/* ---------- Confirm List ---------- */
.confirm-list {
  list-style: decimal;
  padding-left: 1.5rem;
  margin: 1rem 0 1.5rem;
}

.confirm-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.95rem;
}

.confirm-list li:last-child {
  border-bottom: none;
}

.confirm-list .presenter {
  color: #6b7280;
  font-size: 0.88rem;
}

/* ---------- Confirm Actions ---------- */
.confirm-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

/* ---------- Stats (Admin Results) ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* alias: task spec says .stat-card, views use .stat — cover both */
.stat-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #2563eb;
  line-height: 1;
}

.stat-label {
  font-size: 0.82rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Results Table ---------- */
.results-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  font-size: 0.92rem;
}

.results-table thead {
  background: #f9fafb;
}

.results-table th {
  padding: 0.7rem 0.875rem;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #e5e7eb;
}

.results-table td {
  padding: 0.7rem 0.875rem;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.results-table tbody tr:last-child td {
  border-bottom: none;
}

.results-table tbody tr:hover {
  background: #f9fafb;
}

/* ---------- Rank Cell ---------- */
.rank {
  font-size: 1.15rem;
  font-weight: 700;
  color: #2563eb;
  width: 2.5rem;
}

/* ---------- Presenter Cell ---------- */
.presenter {
  color: #6b7280;
  font-size: 0.88rem;
}

/* ---------- Votes Cell ---------- */
.votes {
  font-weight: 600;
  color: #1a1a2e;
  text-align: right;
  white-space: nowrap;
}

/* ---------- Bar Chart ---------- */
.bar-cell {
  width: 120px;
  padding-left: 0.5rem !important;
}

.bar {
  height: 10px;
  background: #2563eb;
  border-radius: 5px;
  min-width: 2px;
  transition: width 0.3s ease;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green {
  background: #dcfce7;
  color: #16a34a;
}

.badge-yellow {
  background: #fef9c3;
  color: #92400e;
}

/* ---------- Admin Actions ---------- */
.admin-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

/* ---------- Responsive tweaks ---------- */
@media (max-width: 480px) {
  h1 {
    font-size: 1.4rem;
  }

  .stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .bar-cell {
    display: none;
  }

  .results-table th,
  .results-table td {
    padding: 0.55rem 0.5rem;
    font-size: 0.82rem;
  }

  .confirm-actions {
    flex-direction: column;
  }

  .confirm-actions .btn {
    width: 100%;
    text-align: center;
  }
}

/* ---------- Topic Form ---------- */
.add-topic-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 500px;
  margin-top: 1rem;
}

.add-topic-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #374151;
}

.input-field {
  padding: 0.6rem 0.85rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
  width: 100%;
  background: #fff;
  transition: border-color 0.15s;
}

.input-field:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
