/* ============================================================
   Sistema de Votaciones Escolares — Estilos principales
   Paleta: azules y verdeazulados fríos, muy tenues
   ============================================================ */

:root {
  --bg-main:        #EEF2F7;
  --bg-card:        #FFFFFF;
  --primary:        #5B8DB8;
  --primary-light:  #7AADD4;
  --primary-dark:   #3D6B91;
  --secondary:      #7FB5B0;
  --accent:         #A8C5E0;
  --sidebar-bg:     #2C4058;
  --sidebar-hover:  #3A5570;
  --sidebar-text:   #B8CCDC;
  --sidebar-active: #FFFFFF;
  --text-dark:      #2C4058;
  --text-medium:    #4A637D;
  --text-light:     #7A95AB;
  --border:         #C8D9E9;
  --border-light:   #E0EAF4;
  --success:        #6BA888;
  --success-bg:     #EAF4EE;
  --warning:        #C9A85C;
  --warning-bg:     #FBF4E6;
  --danger:         #C07878;
  --danger-bg:      #FBEDED;
  --info:           #6898C0;
  --info-bg:        #EAF1F8;
  --shadow:         0 4px 20px rgba(44, 64, 88, .08);
  --shadow-hover:   0 8px 32px rgba(44, 64, 88, .14);
  --radius:         10px;
  --radius-lg:      14px;
}

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

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-main);
  color: var(--text-dark);
  font-size: 15px;
  line-height: 1.6;
}

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

/* ── Tipografía ────────────────────────────────────────────── */
h1,h2,h3,h4 { margin: 0 0 .5rem; font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.9rem; color: var(--text-dark); }
h2 { font-size: 1.4rem; color: var(--text-dark); }
h3 { font-size: 1.1rem; color: var(--text-medium); }
p  { margin: 0 0 1rem; }

/* ── Botones ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .6rem 1.3rem;
  border: none; border-radius: var(--radius);
  font-size: .9rem; font-weight: 500; cursor: pointer;
  transition: background .18s, box-shadow .18s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }

.btn-primary  { background: var(--primary);   color: #fff; }
.btn-primary:hover  { background: var(--primary-dark); color: #fff; }
.btn-secondary{ background: var(--secondary); color: #fff; }
.btn-secondary:hover{ background: #5d9893; color: #fff; }
.btn-success  { background: var(--success);   color: #fff; }
.btn-success:hover  { background: #4d8a6e; color: #fff; }
.btn-danger   { background: var(--danger);    color: #fff; }
.btn-danger:hover   { background: #a55555; color: #fff; }
.btn-outline  { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover  { background: var(--primary); color: #fff; }
.btn-ghost    { background: transparent; color: var(--text-medium); }
.btn-ghost:hover    { background: var(--border-light); }
.btn-sm { padding: .35rem .85rem; font-size: .82rem; }
.btn-lg { padding: .85rem 2rem; font-size: 1.05rem; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 1.8rem;
}
.card-sm { padding: 1.2rem; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.4rem; padding-bottom: 1rem;
  border-bottom: 1.5px solid var(--border-light);
}
.card-header h2 { margin: 0; }

/* ── Alertas ───────────────────────────────────────────────── */
.alert {
  padding: .85rem 1.1rem; border-radius: var(--radius);
  font-size: .9rem; margin-bottom: 1.2rem;
  display: flex; align-items: flex-start; gap: .6rem;
}
.alert-success { background: var(--success-bg); color: #2a6645; border-left: 3px solid var(--success); }
.alert-danger  { background: var(--danger-bg);  color: #7a3838; border-left: 3px solid var(--danger); }
.alert-warning { background: var(--warning-bg); color: #7a5c20; border-left: 3px solid var(--warning); }
.alert-info    { background: var(--info-bg);    color: #2d5478; border-left: 3px solid var(--info); }

/* ── Formularios ───────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block; font-size: .85rem; font-weight: 500;
  color: var(--text-medium); margin-bottom: .38rem;
}
.form-control {
  width: 100%; padding: .65rem .95rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem; color: var(--text-dark);
  background: #fff; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,141,184,.15);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ── Tablas ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse; font-size: .9rem;
}
thead th {
  background: #F4F8FC; color: var(--text-medium);
  font-weight: 600; font-size: .8rem; text-transform: uppercase;
  letter-spacing: .04em; padding: .75rem 1rem;
  border-bottom: 2px solid var(--border);
  text-align: left;
}
tbody td { padding: .7rem 1rem; border-bottom: 1px solid var(--border-light); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #F7FAFE; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .22rem .65rem;
  border-radius: 999px; font-size: .75rem; font-weight: 600;
}
.badge-success { background: var(--success-bg); color: #2a6645; }
.badge-danger  { background: var(--danger-bg);  color: #7a3838; }
.badge-warning { background: var(--warning-bg); color: #7a5c20; }
.badge-info    { background: var(--info-bg);    color: #2d5478; }
.badge-primary { background: #EAF1F8; color: var(--primary-dark); }
.badge-neutral { background: var(--border-light); color: var(--text-medium); }

/* ── Paginación ────────────────────────────────────────────── */
.pagination {
  display: flex; gap: .4rem; align-items: center; margin-top: 1.2rem;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  padding: .4rem .75rem; border-radius: var(--radius);
  font-size: .85rem; border: 1.5px solid var(--border);
  color: var(--text-medium);
}
.pagination a:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

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

.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-logo {
  padding: 1.6rem 1.4rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo h2 {
  color: #fff; font-size: 1rem; margin: 0;
  line-height: 1.4;
}
.sidebar-logo span { color: var(--sidebar-text); font-size: .78rem; }

.sidebar-nav { flex: 1; padding: 1rem 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1.4rem;
  color: var(--sidebar-text); font-size: .9rem;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--sidebar-hover);
  color: var(--sidebar-active);
}
.sidebar-nav a.active { border-left: 3px solid var(--primary-light); }
.sidebar-nav .nav-section {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .08em;
  color: rgba(184,204,220,.5); padding: 1.1rem 1.4rem .3rem;
}
.sidebar-icon { width: 18px; text-align: center; }

.admin-content {
  margin-left: 240px; flex: 1; display: flex; flex-direction: column;
  min-height: 100vh;
}
.admin-topbar {
  background: #fff; border-bottom: 1.5px solid var(--border-light);
  padding: 1rem 2rem; display: flex; align-items: center;
  justify-content: space-between; position: sticky; top: 0; z-index: 50;
}
.admin-topbar h1 { font-size: 1.2rem; margin: 0; color: var(--text-dark); }
.topbar-user { display: flex; align-items: center; gap: .75rem; }
.topbar-user span { font-size: .88rem; color: var(--text-medium); }
.admin-main { flex: 1; padding: 2rem; max-width: 1200px; }

/* ── Grid de estadísticas ──────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.2rem; margin-bottom: 2rem;
}
.stat-card {
  background: #fff; border-radius: var(--radius-lg);
  padding: 1.4rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: .4rem;
}
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-light); }
.stat-value { font-size: 2.2rem; font-weight: 700; color: var(--text-dark); line-height: 1; }
.stat-sub   { font-size: .82rem; color: var(--text-light); }
.stat-icon  { font-size: 1.6rem; margin-bottom: .3rem; }

/* ── Landing ───────────────────────────────────────────────── */
.landing {
  min-height: 100vh; background: var(--bg-main);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; padding: 2rem;
}
.landing-header { text-align: center; margin-bottom: 3rem; }
.landing-header h1 { font-size: 2.2rem; color: var(--text-dark); margin-bottom: .5rem; }
.landing-header p  { font-size: 1.05rem; color: var(--text-medium); }
.landing-cards {
  display: flex; gap: 2rem; flex-wrap: wrap; justify-content: center;
  max-width: 700px;
}
.landing-card {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 2.5rem 2rem;
  text-align: center; cursor: pointer; flex: 1; min-width: 240px;
  transition: box-shadow .2s, transform .2s;
  text-decoration: none; display: block; color: inherit;
}
.landing-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-3px); }
.landing-card .lc-icon { font-size: 3rem; margin-bottom: 1rem; }
.landing-card h2 { color: var(--primary); margin-bottom: .5rem; }
.landing-card p  { color: var(--text-light); font-size: .9rem; margin: 0; }

/* ── Login centrado ────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg-main); padding: 1.5rem;
}
.login-box {
  background: #fff; border-radius: var(--radius-lg);
  box-shadow: var(--shadow); padding: 2.8rem 2.5rem;
  width: 100%; max-width: 420px;
}
.login-box .logo-area { text-align: center; margin-bottom: 2rem; }
.login-box .logo-area .icon { font-size: 3rem; }
.login-box .logo-area h1 { font-size: 1.4rem; margin: .4rem 0 .2rem; }
.login-box .logo-area p { color: var(--text-light); font-size: .88rem; margin: 0; }
.back-link { display: block; text-align: center; margin-top: 1.4rem; font-size: .88rem; color: var(--text-light); }
.back-link a { color: var(--primary); }

/* ── Panel de votación ─────────────────────────────────────── */
.vote-layout { display: flex; min-height: 100vh; flex-direction: column; }
.vote-topbar {
  background: #fff; border-bottom: 1.5px solid var(--border-light);
  padding: .9rem 2rem; display: flex; justify-content: space-between; align-items: center;
}
.vote-topbar .student-info h2 { font-size: 1rem; margin: 0 0 .1rem; }
.vote-topbar .student-info span { font-size: .82rem; color: var(--text-light); }
.vote-main { flex: 1; padding: 2rem; max-width: 900px; margin: 0 auto; width: 100%; }

.section-label {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-light); font-weight: 600; margin-bottom: 1rem;
}

/* Pasos de votación */
.vote-steps {
  display: flex; gap: .5rem; margin-bottom: 2.5rem; flex-wrap: wrap;
}
.vote-step {
  padding: .4rem 1rem; border-radius: 999px; font-size: .8rem;
  border: 1.5px solid var(--border); color: var(--text-light); font-weight: 500;
}
.vote-step.done  { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.vote-step.active{ background: var(--primary);    color: #fff;           border-color: var(--primary); }

/* Grid de candidatos */
.candidates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.2rem; margin-bottom: 1.5rem;
}
.candidate-card {
  background: #fff; border-radius: var(--radius-lg);
  border: 2px solid var(--border-light); padding: 1.2rem;
  text-align: center; cursor: pointer; transition: border-color .18s, box-shadow .18s;
  position: relative;
}
.candidate-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.candidate-card.selected {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,141,184,.2);
}
.candidate-card input[type=radio] {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.candidate-photo {
  width: 80px; height: 80px; border-radius: 50%; object-fit: cover;
  background: var(--border-light); margin: 0 auto .8rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; overflow: hidden;
}
.candidate-photo img { width: 100%; height: 100%; object-fit: cover; }
.candidate-name { font-weight: 600; font-size: .95rem; color: var(--text-dark); margin-bottom: .3rem; }
.candidate-slogan { font-size: .78rem; color: var(--text-light); }
.candidate-check {
  position: absolute; top: .6rem; right: .6rem;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: .8rem; display: none;
  align-items: center; justify-content: center;
}
.candidate-card.selected .candidate-check { display: flex; }

.blank-option {
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  padding: 1rem 1.4rem; text-align: center; cursor: pointer;
  transition: border-color .18s, background .18s; margin-bottom: 1.5rem;
  position: relative;
}
.blank-option:hover { border-color: var(--text-light); background: var(--bg-main); }
.blank-option.selected { border-color: var(--warning); background: var(--warning-bg); }
.blank-option input[type=radio] { position: absolute; opacity: 0; width: 0; height: 0; }
.blank-option span { font-size: .9rem; color: var(--text-medium); }

/* ── Gráficos de resultados ────────────────────────────────── */
.results-bar {
  display: flex; flex-direction: column; gap: .9rem;
}
.result-row { display: flex; flex-direction: column; gap: .3rem; }
.result-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: .88rem; color: var(--text-medium);
}
.result-bar-wrap {
  background: var(--border-light); border-radius: 999px; height: 10px; overflow: hidden;
}
.result-bar-fill {
  height: 100%; border-radius: 999px; background: var(--primary);
  transition: width .6s ease;
}
.result-bar-fill.winner { background: var(--success); }
.result-bar-fill.blank  { background: var(--border); }

/* ── Confirmación ──────────────────────────────────────────── */
.done-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  flex-direction: column; padding: 2rem; text-align: center;
}
.done-icon { font-size: 5rem; margin-bottom: 1.2rem; }
.done-wrap h1 { color: var(--success); margin-bottom: .5rem; }
.done-wrap p  { color: var(--text-medium); font-size: 1.05rem; max-width: 400px; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: 0; overflow: hidden; transition: width .25s; }
  .sidebar.open { width: 240px; }
  .admin-content { margin-left: 0; }
  .admin-main { padding: 1.2rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .candidates-grid { grid-template-columns: 1fr 1fr; }
  .landing-cards { flex-direction: column; max-width: 340px; }
}

/* ── Misceláneos ───────────────────────────────────────────── */
.text-muted    { color: var(--text-light); font-size: .88rem; }
.text-center   { text-align: center; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; } .items-center { align-items: center; } .gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.divider { border: none; border-top: 1.5px solid var(--border-light); margin: 1.5rem 0; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-light); }
.empty-state .es-icon { font-size: 2.5rem; margin-bottom: .8rem; }

/* Indicador de estado de elección */
.election-status {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .8rem; border-radius: 999px; font-size: .8rem; font-weight: 500;
}
.election-status.active { background: var(--success-bg); color: var(--success); }
.election-status.inactive{ background: var(--border-light); color: var(--text-light); }
.election-status.active::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--success); animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; } 50% { opacity: .4; }
}

/* Upload de foto */
.photo-upload { position: relative; cursor: pointer; }
.photo-preview {
  width: 100px; height: 100px; border-radius: 50%; border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 2rem;
  overflow: hidden; background: var(--bg-main);
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

/* Progress circle para participación */
.progress-circle { position: relative; display: inline-block; }
.progress-circle canvas { display: block; }
.progress-circle .pct {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  font-size: 1.5rem; font-weight: 700; color: var(--text-dark);
}
