/* SIDEBAR PANEL - PANEL LATERAL DESLIZABLE */

.sidebar-panel {
  position: fixed;
  top: 0;
  right: -600px; /* 100% Oculto fuera de la pantalla físicamente */
  width: 550px;
  height: 100vh;
  
  background: #ffffff;
  box-shadow: -10px 0 25px rgba(0, 0, 0, 0.1);
  border-radius: 16px 0 0 16px; 
  
  /* Animación física directa, imposible que falle */
  transition: right 0.4s cubic-bezier(0.25, 1, 0.5, 1);
  
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-panel.active {
  right: 0; /* Vuelve a la pantalla */
}

/* Header del sidebar - Estilo Modal */
.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  flex-shrink: 0;
}

.sidebar-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
}

.btn-close-sidebar {
  background: #f5f5f5;
  border: none;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  color: #666;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  line-height: 0;
  padding: 0;
}

.btn-close-sidebar:hover {
  background: #eeeeee;
  color: #000;
}

.btn-close-sidebar:active {
  background: rgba(0, 0, 0, 0.2);
}

body.dark-mode .sidebar-panel,
body.dark-mode .sidebar-header {
  background: #1a1a1a;
  color: #ffffff;
  border-color: #333333;
}

body.dark-mode .sidebar-header h3 {
  color: #ffffff;
}

body.dark-mode .btn-close-sidebar {
  background: #333333;
  color: #cccccc;
}

/* Contenido del sidebar */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* Secciones dentro del sidebar */
.sidebar-section {
  margin-bottom: 32px;
}

.sidebar-section:last-child {
  margin-bottom: 0;
}

.sidebar-section h4 {
  margin: 0 0 16px 0;
  font-size: 15px;
  font-weight: 600;
  color: #4D4D4D;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.sidebar-section-header h4 {
  margin: 0;
}

.combinaciones-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.max-combinaciones-input {
  width: 50px;
  padding: 4px 8px;
  border: 2px solid #E0E0E0;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  font-family: inherit;
  transition: all 0.2s;
}

.max-combinaciones-input:focus {
  outline: none;
  border-color: black;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.max-combinaciones-input::-webkit-inner-spin-button,
.max-combinaciones-input::-webkit-outer-spin-button {
  opacity: 1;
  height: 20px;
}

.btn-regenerar-combinaciones {
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}

.btn-regenerar-combinaciones:hover {
  background: #45a049;
  transform: scale(1.1);
}

.btn-regenerar-combinaciones:active {
  transform: scale(0.95);
}

.count-badge {
  background: black;
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  min-width: 24px;
  text-align: center;
}

/* Búsqueda integrada en sidebar */
.sidebar-search-container {
  position: relative;
}

.sidebar-search-input {
  width: 100%;
  padding: 12px 16px;
  
  /* Glass Morphism */
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  
  font-size: 14px;
  font-family: inherit;
  color: #1A1A1A;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-search-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(0, 0, 0, 0.3);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.sidebar-search-input::placeholder {
  color: #999;
}

.sidebar-search-results {
  max-height: 300px;
  overflow-y: auto;
  margin-top: 12px;
  border-radius: 8px;
  background: #FAFAFA;
}

.sidebar-search-results:empty {
  display: none;
}

.sidebar-search-result-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #E0E0E0;
  transition: all 0.2s;
  background: white;
}

.sidebar-search-result-item:last-child {
  border-bottom: none;
}

.sidebar-search-result-item:hover {
  background: #F0F0F0;
}

.sidebar-search-result-name {
  font-size: 14px;
  font-weight: 500;
  color: #1A1A1A;
  margin-bottom: 4px;
}

.sidebar-search-result-info {
  font-size: 12px;
  color: #666;
}

.sidebar-search-empty {
  padding: 24px;
  text-align: center;
  color: #999;
  font-size: 13px;
}

/* Mensaje vacío */
.sidebar-empty-message {
  text-align: center;
  padding: 24px;
  background: #FAFAFA;
  border-radius: 8px;
  border: 1px dashed #E0E0E0;
}

.sidebar-empty-message p {
  margin: 0 0 4px 0;
  font-size: 14px;
  color: #666;
  font-weight: 500;
}

.sidebar-empty-message span {
  font-size: 12px;
  color: #999;
}

/* Asignaturas seleccionadas en sidebar */
.asignaturas-seleccionadas-sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  align-items: stretch;
}

.asignatura-seleccionada-item-sidebar {
  width: 100%;
  margin: 0;
}

.asignatura-seleccionada-item-sidebar:hover {
  /* Hover manejado por filtros-asignaturas.css */
}

.asignatura-seleccionada-nombre {
  font-size: 14px;
  font-weight: 500;
  color: #1A1A1A;
  flex: 1;
}

/* Botón de filtros (engranaje) */
.btn-filtros-asignatura {
  background: transparent;
  border: none;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
  margin-left: auto;
  margin-right: 8px;
}

.btn-filtros-asignatura:hover {
  background: rgba(0, 0, 0, 0.1);
  transform: scale(1.2);
}

.btn-filtros-asignatura:active {
  transform: scale(0.95);
}

.icon-filtros {
  width: 18px;
  height: 18px;
}

.btn-quitar-asignatura {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  font-size: 20px;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
  flex-shrink: 0;
  margin-left: 0;
}

.btn-quitar-asignatura:hover {
  background: #E0E0E0;
  color: #666;
}

/* Botón agregar asignatura */
.btn-agregar-asignatura {
  width: 100%;
  padding: 14px;
  background: black;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-agregar-asignatura:hover {
  background: #333;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-agregar-asignatura:active {
  transform: translateY(0);
}

/* Header de combinaciones */
.combinaciones-header-sidebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.combinaciones-count {
  background: black;
  color: white;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}

/* Mensaje de sin combinaciones */
.sidebar-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #999;
}

.sidebar-empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.3;
}

.sidebar-empty-state h5 {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: #666;
}

.sidebar-empty-state p {
  margin: 0;
  font-size: 14px;
  color: #999;
}

/* Container de minihorarios en sidebar */
.minihorarios-container-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Ajuste de minihorarios para sidebar */
.sidebar-panel .minihorario-card {
  margin-bottom: 0;
}

.sidebar-panel .mini-tabla {
  font-size: 10px;
}

.sidebar-panel .mini-tabla thead th {
  font-size: 9px;
  padding: 6px 2px;
}

.sidebar-panel .mini-celda {
  padding: 4px 2px;
  height: 32px;
}

.sidebar-panel .mini-celda.hora-col {
  font-size: 9px;
  min-width: 85px;
  width: 85px;
}

.sidebar-panel .mini-asig-nombre {
  font-size: 9px;
}

.sidebar-panel .mini-grupo {
  font-size: 8px;
}

/* Overlay oscuro */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  
  opacity: 0;
  pointer-events: none; 
  transition: opacity 0.4s ease;
  z-index: 999;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto; 
}

/* Scrollbar personalizado para sidebar */
.sidebar-content::-webkit-scrollbar {
  width: 8px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: #F5F5F5;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: #CCC;
  border-radius: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: #999;
}

@media (max-width: 768px) {
  .sidebar-panel {
    width: 100vw;
    right: -100vw; /* Fuera de la pantalla en móviles */
    border-radius: 0;
  }
  .sidebar-panel.active {
    right: 0;
  }
}

/* Botón generar combinaciones */
.btn-generar-combinaciones {
  width: 100%;
  padding: 14px;
  background: #4CAF50;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  margin-top: 12px;
}

.btn-generar-combinaciones:hover {
  background: #45a049;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.btn-generar-combinaciones:disabled {
  background: #CCC;
  cursor: not-allowed;
  transform: none;
}

/* Loading state */
.sidebar-loading {
  text-align: center;
  padding: 32px;
  color: #999;
}

.sidebar-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #F0F0F0;
  border-top-color: black;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}