/**
 * Levels Sidebar Styles
 * ✨ ESTILO MODERNO E LIMPO
 * ✨ CARDS COM GRADIENTE E ANIMAÇÕES
 * 
 * @package Units
 * @version 12.0 - Modern Cards
 */

/* ============================================
   SIDEBAR CONTAINER
   ============================================ */

.levels-sidebar {
  width: 280px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: var(--space-16);
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.levels-sidebar::-webkit-scrollbar {
  width: 6px;
}

.levels-sidebar::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

/* ============================================
   HEADER
   ============================================ */

.levels-sidebar__header {
  margin-bottom: var(--space-20);
}

.nav-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-12);
  padding: var(--space-12) 0;
  border-bottom: 2px solid var(--color-border);
}

.levels-sidebar__title {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.levels-sidebar__title h3 {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.levels-sidebar__icon {
  font-size: 18px;
}

.levels-sidebar__add-btn {
  width: 76px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary) 0%, #4f46e5 100%);
  border: none;
  border-radius: var(--radius-lg);
  color: white;
  font-size: 20px;
  font-weight: var(--font-weight-bold);
  cursor: pointer;
  transition: all var(--duration-fast);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  margin-left: 32%;
}

.levels-sidebar__add-btn:not(.disabled):hover {
  transform: scale(1.18);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.55);
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
}

.levels-sidebar__add-btn:not(.disabled):active {
  transform: scale(1.05);
}

.levels-sidebar__add-btn.disabled {
  background: var(--color-border);
  color: var(--color-text-tertiary);
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.5;
}

/* ✨ Pulsar quando não há nenhum nível criado */
.levels-sidebar__add-btn.pulse-hint {
  animation: addLevelPulse 1.6s cubic-bezier(0.4, 0, 0.6, 1) infinite;
  box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7);
}

@keyframes addLevelPulse {
  0% {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3), 0 0 0 0 rgba(99, 102, 241, 0.5);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3), 0 0 0 8px rgba(99, 102, 241, 0);
    transform: scale(1.06);
  }
  100% {
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3), 0 0 0 0 rgba(99, 102, 241, 0);
    transform: scale(1);
  }
}

/* ============================================
   LIST
   ============================================ */

.levels-sidebar__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  flex: 1;
}

/* ============================================
   LEVEL CARD - ESTILO MODERNO E BONITO
   ============================================ */

.level-card {
  padding: var(--space-14);
  background: linear-gradient(135deg, #ffffff 0%, #fafbff 100%);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: var(--space-12);
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
}

/* Efeito de gradiente sutil no hover */
.level-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--level-color, #6366f1) 0%, transparent 100%);
  opacity: 0;
  transition: opacity var(--duration-fast);
  pointer-events: none;
}

.level-card:hover::before {
  opacity: 0.04;
}

/* HOVER - Lift suave e glow com cores invertidas */
.level-card:hover {
  border-color: var(--level-color, var(--color-primary));
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.18), 0 0 0 1px rgba(99, 102, 241, 0.1);
  background: linear-gradient(135deg, var(--level-color, #6366f1) 0%, var(--level-color, #4f46e5) 100%);
}

/* ✨ Inverter cores no hover (exceto rascunhos) */
.level-card:not(.level-card--draft):hover .level-card__name,
.level-card:not(.level-card--draft):hover .level-card__count {
  color: white;
}

.level-card:not(.level-card--draft):hover .level-card__indicator {
  background: linear-gradient(135deg, #ffffff 0%, #f0f2ff 100%);
  box-shadow: 0 8px 24px rgba(255, 255, 255, 0.6), inset 0 -1px 2px rgba(99, 102, 241, 0.15);
}

.level-card:not(.level-card--draft):hover .level-card__number {
  color: var(--level-color, var(--color-primary));
}

.level-card:not(.level-card--draft):hover .level-card__count {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.2) 100%);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

/* ACTIVE - Destaque forte e vibrante */
.level-card--active {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  border-color: #4338ca;
  color: white;
  box-shadow: 0 8px 28px rgba(99, 102, 241, 0.45), 0 0 0 2px rgba(99, 102, 241, 0.2);
  transform: translateY(-3px) scale(1.03);
}

/* 🔳 ACTIVE + DRAFT (Level Órfão Selecionado) - TEXTO PRETO PARA CONTRASTE */
.level-card--active.level-card--draft {
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  border-color: #d97706;
  color: #000000; /* ✨ TEXTO PRETO */
  box-shadow: 0 8px 28px rgba(245, 158, 11, 0.45), 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.level-card--active.level-card--draft .level-card__name,
.level-card--active.level-card--draft .level-card__count {
  color: #000000; /* ✨ TEXTO PRETO */
}

.level-card--active.level-card--draft .level-card__number {
  color: #000000; /* ✨ NÚMERO PRETO */
}

.level-card--active::before {
  opacity: 0;
}

/* Draft state */
.level-card--draft {
  border-style: dashed;
  border-color: var(--color-warning);
  background: rgba(245, 158, 11, 0.05);
}

.level-card--draft:hover {
  border-color: var(--color-warning);
  background: rgba(245, 158, 11, 0.08);
}

/* ============================================
   INDICATOR (Círculo com número e gradiente)
   ============================================ */

.level-card__indicator {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--level-color, #6366f1) 0%, #4338ca 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(99, 102, 241, 0.3), inset 0 1px 2px rgba(255, 255, 255, 0.2);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

/* Efeito de anel pulsante */
.level-card__indicator::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--level-color, #6366f1);
  opacity: 0;
  animation: levelRingPulse 2s ease-in-out infinite;
}

@keyframes levelRingPulse {
  0%, 100% {
    opacity: 0;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(1.1);
  }
}

.level-card:hover .level-card__indicator {
  transform: scale(1.15) rotate(5deg);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.level-card--active .level-card__indicator {
  background: linear-gradient(135deg, #ffffff 0%, #f0f2ff 100%);
  box-shadow: 0 8px 24px rgba(255, 255, 255, 0.6), inset 0 -1px 2px rgba(99, 102, 241, 0.15);
}

/* 🔳 Indicador do level órfão ativo - fundo branco com número preto */
.level-card--active.level-card--draft .level-card__indicator {
  background: linear-gradient(135deg, #ffffff 0%, #fef3c7 100%);
  box-shadow: 0 8px 24px rgba(255, 255, 255, 0.8), inset 0 -1px 2px rgba(245, 158, 11, 0.2);
}

.level-card--active .level-card__indicator::after {
  border-color: white;
}

.level-card__number {
  font-size: 18px;
  font-weight: 900;
  color: white;
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.level-card--active .level-card__number {
  color: var(--color-primary);
}

/* ============================================
   CONTENT
   ============================================ */

.level-card__content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.level-card__name {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.level-card--active .level-card__name {
  color: white;
}

.level-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.level-card__count {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  font-weight: 600;
  padding: 3px 10px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
}

.level-card--active .level-card__count {
  color: white;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0.2) 100%);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

/* ============================================
   BADGE
   ============================================ */

.level-card__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  white-space: nowrap;
}

.level-card__badge--draft {
  background: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  color: white;
  box-shadow: 0 3px 12px rgba(245, 158, 11, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.2);
  font-weight: 800;
}

.level-card__draft-hint {
  font-size: 10px;
  color: var(--color-text-tertiary);
  line-height: 1.4;
  margin-top: var(--space-4);
  font-weight: var(--font-weight-medium);
  opacity: 0.85;
}

.level-card--active .level-card__draft-hint {
  color: rgba(0, 0, 0, 0.55);
}

/* ============================================
   ACTIONS
   ============================================ */

.level-card__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  transition: opacity var(--duration-fast);
}

.level-card__edit-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08) 0%, rgba(99, 102, 241, 0.12) 100%);
  border: 1.5px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-lg);
  color: var(--color-primary);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 17px;
}

.level-card__edit-icon:hover {
  background: linear-gradient(135deg, var(--color-primary) 0%, #4338ca 100%);
  border-color: #4338ca;
  color: white;
  transform: scale(1.15) rotate(5deg);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

.level-card__delete-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(239, 68, 68, 0.12) 100%);
  border: 1.5px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-lg);
  color: var(--color-error);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 17px;
}

.level-card__delete-btn:hover {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-color: #dc2626;
  color: white;
  transform: scale(1.15) rotate(-5deg);
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

/* ============================================
   FOOTER
   ============================================ */

.levels-sidebar__hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  text-align: center;
  margin: 0;
  line-height: 1.6;
  font-weight: var(--font-weight-medium);
  padding: var(--space-8) var(--space-12);
  background: var(--color-background);
  border-radius: var(--radius-md);
}

.levels-sidebar__hint--warning {
  background: rgba(245, 158, 11, 0.08);
  color: var(--color-warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
  font-weight: var(--font-weight-semibold);
}

/* ============================================
   EMPTY STATE
   ============================================ */

.levels-sidebar__empty {
  text-align: center;
  padding: var(--space-40) var(--space-24);
  color: var(--color-text-secondary);
}

.levels-sidebar__empty::before {
  content: '📊';
  font-size: 48px;
  display: block;
  margin-bottom: var(--space-16);
  opacity: 0.5;
}

.levels-sidebar__empty p {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-8) 0;
  color: var(--color-text);
}

.levels-sidebar__empty small {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes slideInFromLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.level-card {
  animation: slideInFromLeft 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  animation-fill-mode: both;
}

.level-card:nth-child(1) { animation-delay: 0ms; }
.level-card:nth-child(2) { animation-delay: 60ms; }
.level-card:nth-child(3) { animation-delay: 120ms; }
.level-card:nth-child(4) { animation-delay: 180ms; }
.level-card:nth-child(5) { animation-delay: 240ms; }
.level-card:nth-child(n+6) { animation-delay: 300ms; }

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .levels-sidebar {
    width: 240px;
    padding: var(--space-12);
  }

  .level-card {
    padding: var(--space-14);
    gap: var(--space-12);
  }

  .level-card__indicator {
    width: 42px;
    height: 42px;
  }

  .level-card__number {
    font-size: 18px;
  }
  
  .levels-sidebar__add-btn {
    width: 32px;
    height: 32px;
    font-size: 18px;
  }
}