/* Portal Sidebar Styles - Shared across all portal pages */

/* SIDEBAR CONTAINER */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-soft);
  padding: 18px 14px 0 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 20;
  justify-content: space-between;
}

/* SIDEBAR CONTENT (Header + Nav) */
.sidebar-content {
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.sidebar-header img { 
  height: 24px; 
}

.sidebar-header span { 
  font-size: 0.95rem; 
  font-weight: 700; 
}

.sidebar-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin: 10px 4px 6px;
  flex-shrink: 0;
}

/* Más espacio antes de la segunda sección (Documentación) */
.sidebar-section-label:not(:first-of-type) {
  margin-top: 20px;
}

/* Sección colapsable de Documentación */
.sidebar-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  margin-top: 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.2s ease;
  user-select: none;
}

.sidebar-section-toggle:hover {
  background: #f8fafc;
  color: var(--text-main);
}

.sidebar-section-toggle span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-section-toggle span i {
  font-size: 0.85rem;
  width: 16px;
  text-align: center;
}

.sidebar-section-toggle .toggle-icon {
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}

.sidebar-section-toggle.expanded .toggle-icon {
  transform: rotate(180deg);
}

.sidebar-section-toggle.expanded {
  color: var(--text-main);
}

/* Lista colapsable */
.sidebar-nav-collapsible {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease-out, opacity 0.2s ease;
  opacity: 0;
}

.sidebar-nav-collapsible.show {
  max-height: 300px;
  opacity: 1;
}

.sidebar-nav-collapsible .sidebar-link {
  padding-left: 18px;
  font-size: 0.82rem;
}

.sidebar-nav { 
  list-style: none; 
  padding: 0; 
  margin: 0;
  flex-shrink: 0;
}

.sidebar-nav li { 
  margin-bottom: 4px; 
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.86rem;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
}

.sidebar-link i {
  width: 16px;
  text-align: center;
  font-size: 0.85rem;
}

.sidebar-icon-img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
  image-rendering: auto;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.sidebar-link.active,
.sidebar-link:hover {
  background: #eef2ff;
  color: var(--text-main);
}

.sidebar-link.active .sidebar-icon-img,
.sidebar-link:hover .sidebar-icon-img {
  filter: brightness(0) !important;
  opacity: 1 !important;
}

/* MT5 image - menos oscuro cuando está activo */
.sidebar-link.active .sidebar-icon-img[alt="MT5"],
.sidebar-link:hover .sidebar-icon-img[alt="MT5"] {
  filter: brightness(0.7) !important;
  opacity: 1 !important;
}

/* CTA Link - Destacado para suscripción */
.sidebar-link-subscribe {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  border: none;
  color: white !important;
  font-weight: 700;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 0.9rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(22, 163, 74, 0.4);
  transform: translateY(0);
}

.sidebar-link-subscribe::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.6s;
}

.sidebar-link-subscribe:hover::before {
  left: 100%;
}

.sidebar-link-subscribe:hover {
  background: linear-gradient(135deg, #15803d 0%, #16a34a 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(22, 163, 74, 0.6);
}

.sidebar-link-subscribe:active {
  transform: translateY(0);
  box-shadow: 0 4px 15px rgba(22, 163, 74, 0.4);
}

.sidebar-link-subscribe.active {
  background: linear-gradient(135deg, #0f5132 0%, #0d4426 100%);
  color: white !important;
  box-shadow: 0 6px 20px rgba(15, 81, 50, 0.5);
}

.subscribe-content {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  width: 100%;
  position: relative;
  z-index: 2;
  gap: 8px;
}

.subscribe-star {
  font-size: 0.85rem;
  color: #fbbf24;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
  animation: star-pulse 2s ease-in-out infinite;
}

@keyframes star-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.8; }
}

.subscribe-text {
  font-weight: 700;
  font-size: 0.9rem;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  letter-spacing: 0.025em;
}

/* Responsive para móviles */
@media (max-width: 767px) {
  .subscribe-content {
    padding: 10px 14px;
  }

  .subscribe-text {
    font-size: 0.85rem;
  }
}

/* SIDEBAR FOOTER - Siempre al final */
.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  border-top: 1px solid var(--border-soft);
  flex-shrink: 0;
  margin-top: auto;
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 14px 12px 14px;
  margin-bottom: 12px;
  position: relative;
}

.sidebar-user-info::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border-soft);
}

.sidebar-user-email {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-main);
  font-weight: 500;
}

.sidebar-user-email i {
  color: var(--text-muted);
  font-size: 0.75rem;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}

.sidebar-email-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-accounts-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-accounts-info i {
  color: var(--text-muted);
  font-size: 0.7rem;
  flex-shrink: 0;
  width: 14px;
  text-align: center;
}

.sidebar-accounts-text {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-accounts-text strong {
  color: var(--text-main);
  font-weight: 600;
}

.sidebar-footer .sidebar-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  transition: all 0.2s ease;
  text-decoration: none;
  margin: 0 14px;
  margin-bottom: 12px;
}

.sidebar-footer .sidebar-link.sidebar-logout:hover {
  background: rgba(220, 38, 38, 0.08);
  color: #dc2626;
}

.sidebar-footer .sidebar-link i {
  font-size: 0.85rem;
}

.plan-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
}

/* MOBILE SIDEBAR - Drawer desde la izquierda */
@media (max-width: 991.98px) {
  aside.sidebar {
    position: fixed !important;
    left: -280px;
    top: 0;
    height: 100vh;
    width: 280px;
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    display: none !important; /* Oculto por defecto en móvil */
  }

  aside.sidebar.mobile-open {
    left: 0 !important;
    display: flex !important; /* Mostrar cuando está abierto */
    flex-direction: column !important;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
  }

  .sidebar-overlay.active {
    display: block;
    animation: fadeIn 0.2s ease;
  }

  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
}

/* DESKTOP SIDEBAR */
@media (min-width: 992px) {
  aside.sidebar.d-lg-block {
    display: flex !important;
    flex-direction: column;
  }

  .sidebar-overlay {
    display: none !important;
  }
}

/* MOBILE MENU BUTTON */
.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 1.2rem;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
  margin-right: 12px;
}

.mobile-menu-btn:hover {
  background: var(--bg-subtle);
}

@media (max-width: 991.98px) {
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}