/* ============================================================
   SISTEMA DE VOTAÇÃO – Estilos principais
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #2563eb;
  --primary-dk: #1d4ed8;
  --success:    #16a34a;
  --danger:     #dc2626;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-600:   #4b5563;
  --gray-700:   #374151;
  --gray-800:   #1f2937;
  --radius:     12px;
  --shadow:     0 2px 16px rgba(0,0,0,.10);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ─────────────────────────────────────────── */
.site-header {
  background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
  color: #fff;
  padding: 2rem 1rem 3rem;
  text-align: center;
}
.site-header h1 { font-size: clamp(1.4rem, 4vw, 2rem); font-weight: 700; }
.site-header p  { opacity: .85; margin-top: .4rem; font-size: .95rem; }

/* ── Contêiner ──────────────────────────────────────── */
.container {
  max-width: 860px;
  margin: -1.5rem auto 3rem;
  padding: 0 1rem;
}

/* ── Cards de Categoria ─────────────────────────────── */
.category-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.category-card__header {
  background: linear-gradient(90deg, #eff6ff, #dbeafe);
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-200);
}
.category-card__header h2 { font-size: 1.1rem; color: var(--primary-dk); }
.category-card__header p  { font-size: .85rem; color: var(--gray-600); margin-top: .2rem; }
.category-card__body { padding: 1.25rem; }

/* ── Grid de Candidatos ─────────────────────────────── */
.candidates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .75rem;
}

.candidate-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: 1rem .75rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--gray-50);
  cursor: pointer;
  transition: all .2s ease;
  text-align: center;
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--gray-700);
  user-select: none;
}
.candidate-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: #eff6ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37,99,235,.15);
}
.candidate-btn.selected {
  border-color: var(--primary);
  background: #dbeafe;
  color: var(--primary-dk);
}
.candidate-btn.selected::after {
  content: '✓';
  position: absolute;
  top: .4rem; right: .5rem;
  font-size: .8rem;
  color: var(--primary);
  font-weight: 800;
}
.candidate-btn:disabled { opacity: .6; cursor: not-allowed; }
.candidate-btn__name { font-size: .9rem; }
.candidate-btn__desc { font-size: .75rem; color: var(--gray-600); font-weight: 400; }

/* ── Botão Votar ────────────────────────────────────── */
.vote-btn {
  margin-top: 1rem;
  width: 100%;
  padding: .75rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .1s;
}
.vote-btn:hover:not(:disabled) { background: var(--primary-dk); }
.vote-btn:active:not(:disabled) { transform: scale(.98); }
.vote-btn:disabled { background: var(--gray-200); color: var(--gray-600); cursor: default; }

/* ── Feedback inline ────────────────────────────────── */
.category-feedback {
  margin-top: .75rem;
  padding: .7rem 1rem;
  border-radius: 8px;
  font-size: .9rem;
  display: none;
}
.category-feedback.success { background: #dcfce7; color: #166534; display: block; }
.category-feedback.error   { background: #fee2e2; color: #991b1b; display: block; }
.category-feedback.voted   { background: #fef9c3; color: #713f12; display: block; }

/* ── Mensagem já votou (estado inicial) ─────────────── */
.already-voted-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: #fef9c3;
  color: #713f12;
  font-size: .8rem;
  font-weight: 600;
  padding: .3rem .7rem;
  border-radius: 999px;
  margin-bottom: .75rem;
}

/* ── Loader spinner ─────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 1rem; height: 1rem;
  border: 2px solid rgba(255,255,255,.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: .3rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ─────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: .8rem;
  color: var(--gray-600);
}

/* ── Admin Layout ───────────────────────────────────── */
.admin-wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--gray-800);
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar__brand {
  padding: 1.25rem 1rem;
  font-weight: 700;
  font-size: 1rem;
  background: rgba(0,0,0,.25);
  color: #fff;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.sidebar__nav { flex: 1; padding: .75rem 0; }
.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem;
  color: #9ca3af;
  font-size: .9rem;
  transition: all .15s;
}
.sidebar__nav a:hover,
.sidebar__nav a.active {
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
}
.sidebar__nav a.active { border-left: 3px solid var(--primary); padding-left: calc(1rem - 3px); }
.sidebar__nav .icon { width: 1.1rem; text-align: center; }
.sidebar__footer { padding: .75rem 1rem; font-size: .8rem; color: #6b7280; }

.main-content { flex: 1; padding: 1.5rem; overflow-x: auto; }

.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; color: var(--gray-800); }
.page-header p   { font-size: .9rem; color: var(--gray-600); margin-top: .25rem; }

/* ── Stats cards ────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.stat-card__label { font-size: .8rem; color: var(--gray-600); text-transform: uppercase; letter-spacing: .05em; }
.stat-card__value { font-size: 2rem; font-weight: 800; color: var(--primary); margin-top: .25rem; }

/* ── Table ──────────────────────────────────────────── */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card__header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.card__header h2 { font-size: 1rem; color: var(--gray-800); }
.card__body { padding: 1.25rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .75rem 1rem; font-size: .9rem; }
th { background: var(--gray-50); color: var(--gray-600); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--gray-200); }
tr:not(:last-child) td { border-bottom: 1px solid var(--gray-100); }
tr:hover td { background: var(--gray-50); }

/* ── Forms ──────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 600; color: var(--gray-700); margin-bottom: .35rem; }
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: .6rem .9rem;
  font-size: .9rem;
  font-family: inherit;
  outline: none;
  transition: border .2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 80px; }

/* ── Buttons ────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem 1rem; border: none;
       border-radius: 8px; font-size: .875rem; font-weight: 600; cursor: pointer; transition: all .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dk); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-ghost   { background: transparent; color: var(--gray-600); border: 1px solid var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }

/* ── Badges ─────────────────────────────────────────── */
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-gray   { background: var(--gray-200); color: var(--gray-600); }
.badge-blue   { background: #dbeafe; color: #1e40af; }

/* ── Alert ──────────────────────────────────────────── */
.alert { padding: .85rem 1rem; border-radius: 8px; font-size: .9rem; margin-bottom: 1rem; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-danger  { background: #fee2e2; color: #991b1b; }
.alert-info    { background: #dbeafe; color: #1e40af; }

/* ── Results bar ────────────────────────────────────── */
.result-bar-wrap { margin-bottom: .75rem; }
.result-bar-label { display: flex; justify-content: space-between; font-size: .875rem; margin-bottom: .3rem; }
.result-bar-label .name  { font-weight: 600; color: var(--gray-700); }
.result-bar-label .count { color: var(--gray-600); }
.result-bar-track { background: var(--gray-200); border-radius: 999px; height: 10px; overflow: hidden; }
.result-bar-fill  { background: linear-gradient(90deg, #2563eb, #60a5fa); height: 100%;
                    border-radius: 999px; transition: width .6s ease; }
.result-bar-fill.winner { background: linear-gradient(90deg, #16a34a, #4ade80); }

/* ── Login page ─────────────────────────────────────── */
.login-page { display: flex; justify-content: center; align-items: center; min-height: 100vh;
              background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%); padding: 1rem; }
.login-card { background: #fff; border-radius: 16px; padding: 2rem; width: 100%; max-width: 380px;
              box-shadow: 0 8px 40px rgba(0,0,0,.25); }
.login-card__logo { text-align: center; font-size: 2.5rem; margin-bottom: .5rem; }
.login-card h1 { text-align: center; font-size: 1.3rem; color: var(--gray-800); margin-bottom: .25rem; }
.login-card p  { text-align: center; font-size: .85rem; color: var(--gray-600); margin-bottom: 1.5rem; }

/* ── Toggle switch ──────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; gap: .5rem; }
.toggle { position: relative; width: 42px; height: 24px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--gray-200); border-radius: 24px; transition: .2s; }
.toggle-slider::before { content: ''; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
                         background: #fff; border-radius: 50%; transition: .2s; }
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 640px) {
  .candidates-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .sidebar { display: none; }
  .main-content { padding: 1rem; }
}
