/* ========================================
   VOTACIONES - ESTILOS PRINCIPALES
   ======================================== */

/* Variables de color para consistencia */
:root {
  --votaciones-primary: #1e40af;
  --votaciones-secondary: #374151;
  --votaciones-accent: #fb923c;
  --votaciones-success: #22c55e;
  --votaciones-danger: #ef4444;
  --votaciones-warning: #f59e0b;
  --votaciones-bg-gray: #f9fafb;
  --votaciones-border: #e5e7eb;
}

/* ========================================
   LAYOUT PRINCIPAL
   ======================================== */

.votaciones-page {
  display: flex;
  min-height: calc(100vh - 80px);
  background-color: var(--votaciones-bg-gray);
  gap: 0;
  overflow: visible; /* Permitir que elementos posicionados absolutamente se vean fuera */
}

.votaciones-container {
  display: flex;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  background-color: white;
  position: relative;
  align-items: flex-start; /* Alinear items al inicio para evitar problemas de altura */
  overflow: visible; /* Permitir que elementos posicionados absolutamente se vean fuera */
}

/* ========================================
   SIDEBAR NAVEGACIÓN
   ======================================== */

.votaciones-sidebar {
  background-color: var(--votaciones-secondary);
  color: white;
  transition: width 0.3s ease;
  min-height: calc(100vh - 80px);
  position: relative;
  border-right: 1px solid #1f2937;
  overflow-y: auto;
  overflow-x: visible; /* Permitir que el botón toggle se vea fuera del sidebar */
  z-index: 50; /* Asegurar que el sidebar esté por encima del contenido */
}

.votaciones-sidebar.collapsed {
  width: 80px;
  min-width: 80px;
}

.votaciones-sidebar.expanded {
  width: 280px;
  min-width: 280px;
}

/* Header del sidebar */
.votaciones-sidebar-header {
  padding: 1.5rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background-color: #1f2937;
}

.votaciones-sidebar-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--votaciones-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.votaciones-sidebar.collapsed .votaciones-sidebar-title {
  display: none;
}

/* Botón de toggle */
.votaciones-sidebar-toggle {
  position: absolute;
  top: 1.5rem;
  right: 8px; /* Cambiado de -12px a 8px para que esté dentro del sidebar */
  background-color: var(--votaciones-accent);
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s ease;
  z-index: 101; /* Mayor z-index que el sidebar para estar por encima de todo */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.votaciones-sidebar-toggle:hover {
  background-color: #ea580c;
  transform: scale(1.1);
}

/* Menú de navegación */
.votaciones-sidebar-nav {
  padding: 0.5rem 0;
}

.votaciones-sidebar-item {
  display: flex;
  align-items: center;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 4px solid transparent;
  gap: 1rem;
  text-decoration: none;
  color: white;
}

.votaciones-sidebar-item:hover {
  background-color: rgba(251, 146, 60, 0.1);
  border-left-color: var(--votaciones-accent);
}

.votaciones-sidebar-item.active {
  background-color: rgba(251, 146, 60, 0.2);
  border-left-color: var(--votaciones-accent);
  font-weight: 600;
}

.votaciones-sidebar-item-icon {
  font-size: 1.25rem;
  min-width: 24px;
  text-align: center;
  color: var(--votaciones-accent);
}

.votaciones-sidebar-item-text {
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.3s ease;
}

.votaciones-sidebar.collapsed .votaciones-sidebar-item-text {
  opacity: 0;
  width: 0;
}

.votaciones-sidebar.collapsed .votaciones-sidebar-item {
  justify-content: center;
  padding: 1rem 0.5rem;
}

/* Scrollbar personalizado para sidebar */
.votaciones-sidebar::-webkit-scrollbar {
  width: 6px;
}

.votaciones-sidebar::-webkit-scrollbar-track {
  background: #1f2937;
}

.votaciones-sidebar::-webkit-scrollbar-thumb {
  background: #4b5563;
  border-radius: 3px;
}

.votaciones-sidebar::-webkit-scrollbar-thumb:hover {
  background: #6b7280;
}

/* ========================================
   CONTENIDO PRINCIPAL
   ======================================== */

.votaciones-content {
  flex: 1;
  min-width: 0;
  padding: 2rem;
  padding-left: 5rem; /* Aumentado de 3rem a 5rem para dar más espacio */
  overflow-y: auto;
  background-color: var(--votaciones-bg-gray);
  margin-left: 20px; /* Margen izquierdo adicional para evitar superposición */
  position: relative;
  z-index: 1; /* Asegurar que el contenido esté por debajo del sidebar */
}

.votaciones-content-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--votaciones-border);
}

.votaciones-content-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--votaciones-secondary);
  margin-bottom: 0.5rem;
}

.votaciones-content-subtitle {
  font-size: 1rem;
  color: #6b7280;
}

/* Scrollbar personalizado para contenido */
.votaciones-content::-webkit-scrollbar {
  width: 8px;
}

.votaciones-content::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.votaciones-content::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.votaciones-content::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ========================================
   TARJETAS DE ESTADÍSTICAS
   ======================================== */

.tarjeta-estadistica {
  background-color: white;
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid var(--votaciones-border);
}

.tarjeta-estadistica:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.tarjeta-estadistica-header {
  background-color: var(--votaciones-accent);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.025em;
  box-shadow: 0 2px 4px rgba(251, 146, 60, 0.3);
}

.tarjeta-estadistica-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tarjeta-estadistica-legend {
  display: flex;
  justify-content: space-around;
  margin-bottom: 0.5rem;
  gap: 0.5rem;
}

.tarjeta-estadistica-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.tarjeta-estadistica-legend-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.tarjeta-estadistica-legend-color.abiertas {
  background-color: var(--votaciones-success);
}

.tarjeta-estadistica-legend-color.cerradas {
  background-color: var(--votaciones-danger);
}

.tarjeta-estadistica-barra-container {
  position: relative;
  height: 40px;
  background-color: #f3f4f6;
  border-radius: 0.5rem;
  overflow: hidden;
  display: flex;
}

.tarjeta-estadistica-barra {
  height: 100%;
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  color: white;
}

.tarjeta-estadistica-barra.abiertas {
  background-color: var(--votaciones-success);
}

.tarjeta-estadistica-barra.cerradas {
  background-color: var(--votaciones-danger);
}

.tarjeta-estadistica-valores {
  display: flex;
  justify-content: space-between;
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

.tarjeta-estadistica-valor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.tarjeta-estadistica-valor-numero {
  font-size: 1.25rem;
  font-weight: 700;
}

.tarjeta-estadistica-valor-numero.abiertas {
  color: var(--votaciones-success);
}

.tarjeta-estadistica-valor-numero.cerradas {
  color: var(--votaciones-danger);
}

.tarjeta-estadistica-valor-porcentaje {
  font-size: 0.75rem;
  color: #6b7280;
}

/* Grid de tarjetas */
.votaciones-tarjetas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* ========================================
   SELECTOR DE ELECCIÓN
   ======================================== */

.votaciones-selector {
  background-color: white;
  border-radius: 0.75rem;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.votaciones-selector-title {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--votaciones-secondary);
}

.votaciones-selector-opciones {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.votaciones-selector-opcion {
  padding: 1rem 2rem;
  font-size: 1.125rem;
  font-weight: 600;
  border: 2px solid var(--votaciones-border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: white;
  color: var(--votaciones-secondary);
}

.votaciones-selector-opcion:hover {
  background-color: var(--votaciones-bg-gray);
  border-color: var(--votaciones-accent);
}

.votaciones-selector-opcion.active {
  background-color: var(--votaciones-accent);
  border-color: var(--votaciones-accent);
  color: white;
  box-shadow: 0 4px 6px rgba(251, 146, 60, 0.3);
}

/* ========================================
   FILTROS GEOGRÁFICOS
   ======================================== */

.votaciones-filtros {
  background-color: white;
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.votaciones-filtros-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.votaciones-filtro {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.votaciones-filtro-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--votaciones-secondary);
}

.votaciones-filtro-select {
  padding: 0.5rem;
  border: 1px solid var(--votaciones-border);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  background-color: white;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.votaciones-filtro-select:focus {
  outline: none;
  border-color: var(--votaciones-accent);
  box-shadow: 0 0 0 3px rgba(251, 146, 60, 0.1);
}

/* ========================================
   TABLAS
   ======================================== */

.votaciones-tabla {
  background-color: white;
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.votaciones-tabla-header {
  background-color: var(--votaciones-secondary);
  color: white;
  padding: 1rem 1.5rem;
  font-weight: 600;
  font-size: 1rem;
}

.votaciones-tabla-contenido {
  overflow-x: auto;
}

.votaciones-tabla table {
  width: 100%;
  border-collapse: collapse;
}

.votaciones-tabla th {
  background-color: #f9fafb;
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--votaciones-secondary);
  border-bottom: 2px solid var(--votaciones-border);
}

.votaciones-tabla td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: #374151;
  border-bottom: 1px solid var(--votaciones-border);
}

.votaciones-tabla tr:hover {
  background-color: var(--votaciones-bg-gray);
}

/* Botones de descarga en tablas */
.votaciones-tabla-btn {
  background-color: var(--votaciones-success);
  color: white;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 0 0.25rem;
}

.votaciones-tabla-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.votaciones-tabla-btn.disabled {
  background-color: #d1d5db;
  cursor: not-allowed;
}

.votaciones-tabla-btn.disabled:hover {
  transform: none;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 1024px) {
  .votaciones-sidebar.expanded {
    width: 240px;
    min-width: 240px;
  }

  .votaciones-content {
    padding: 1.5rem;
  }

  .votaciones-tarjetas-grid {
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  }
}

@media (max-width: 768px) {
  .votaciones-page {
    flex-direction: column;
  }

  .votaciones-container {
    flex-direction: column;
  }

  .votaciones-sidebar {
    width: 100%;
    min-width: 100%;
    max-height: 60px;
    min-height: auto;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid #1f2937;
  }

  .votaciones-sidebar.collapsed {
    max-height: 60px;
  }

  .votaciones-sidebar.expanded {
    max-height: 400px;
    overflow-y: auto;
  }

  .votaciones-sidebar-nav {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    padding: 0;
  }

  .votaciones-sidebar.expanded .votaciones-sidebar-nav {
    flex-direction: column;
  }

  .votaciones-sidebar-item {
    flex-direction: column;
    padding: 1rem;
    min-width: 80px;
    border-left: none;
    border-bottom: 4px solid transparent;
  }

  .votaciones-sidebar-item.active {
    border-left: none;
    border-bottom-color: var(--votaciones-accent);
  }

  .votaciones-sidebar-item-text {
    font-size: 0.75rem;
    text-align: center;
  }

  .votaciones-sidebar-toggle {
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
  }

  .votaciones-content {
    padding: 1rem;
  }

  .votaciones-content-title {
    font-size: 1.5rem;
  }

  .votaciones-tarjetas-grid {
    grid-template-columns: 1fr;
  }

  .votaciones-filtros-grid {
    grid-template-columns: 1fr;
  }

  .votaciones-selector-opciones {
    flex-direction: column;
  }

  .votaciones-selector-opcion {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .votaciones-content {
    padding: 0.75rem;
  }

  .tarjeta-estadistica {
    padding: 1rem;
  }

  .tarjeta-estadistica-header {
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
  }

  .votaciones-tabla th,
  .votaciones-tabla td {
    padding: 0.5rem;
    font-size: 0.75rem;
  }
}

/* ========================================
   ANIMACIONES
   ======================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.votaciones-content > * {
  animation: fadeIn 0.3s ease-out;
}

/* ========================================
   UTILIDADES
   ======================================== */

.votaciones-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.votaciones-badge.success {
  background-color: #dcfce7;
  color: #166534;
}

.votaciones-badge.danger {
  background-color: #fee2e2;
  color: #991b1b;
}

.votaciones-badge.warning {
  background-color: #fef3c7;
  color: #92400e;
}

.votaciones-badge.info {
  background-color: #dbeafe;
  color: #1e40af;
}
