/* === RAILBAN NEXT v8.0: Mega-Menu, Persistent Mini-Player, Skeletons & Modular Hub === */

/* 1. Menú "Más" Compacto (2 columnas limpias, sin ocupar media pantalla) */
@media (min-width: 768px) {
  .nav-dropdown-menu.mega-menu {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(175px, 1fr)) !important;
    gap: 8px 12px !important;
    min-width: 380px !important;
    max-width: 430px !important;
    max-height: 75vh !important;
    overflow-y: auto !important;
    padding: 10px 12px !important;
    right: -24px !important;
    left: auto !important;
    border-radius: 16px !important;
    border: 1px solid rgba(0, 242, 254, 0.25) !important;
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.65), 0 0 20px rgba(0, 242, 254, 0.1) !important;
  }
  .nav-dropdown:not(.active) .nav-dropdown-menu.mega-menu {
    display: none !important;
  }
  .mega-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .mega-col-title {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--primary, #00f2fe);
    padding: 2px 6px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 3px;
  }
  .mega-col a {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 5px 8px !important;
    border-radius: 8px !important;
    font-size: 0.8rem !important;
    line-height: 1.2 !important;
  }
  .mega-item-meta {
    display: flex;
    flex-direction: column;
  }
  .mega-item-sub {
    display: none !important;
  }
}

/* 2. Mini-Player Global Persistente */
.rb-mini-player {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 45000;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  max-width: 390px;
  width: calc(100vw - 36px);
  background: rgba(10, 15, 30, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(0, 242, 254, 0.35);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 24px rgba(0, 242, 254, 0.16);
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
}
.rb-mini-player.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.rb-mini-cover {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid rgba(0, 242, 254, 0.4);
  flex-shrink: 0;
}
.rb-mini-info {
  flex: 1;
  min-width: 0;
}
.rb-mini-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rb-mini-sub {
  font-size: 0.72rem;
  color: var(--primary, #00f2fe);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rb-mini-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.rb-mini-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  transition: transform 0.18s ease, background-color 0.18s ease, border-color 0.18s ease;
}
.rb-mini-btn:hover {
  background: var(--primary, #00f2fe);
  color: #05070e;
  border-color: var(--primary, #00f2fe);
  transform: scale(1.08);
}

/* 3. Skeleton Loaders & Estados Vacíos Ilustrados */
.rb-skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(0,242,254,0.12) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: rbShimmer 1.4s infinite linear;
  border-radius: 12px;
  min-height: 64px;
}
@keyframes rbShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.rb-empty-state {
  text-align: center;
  padding: 36px 20px;
  border: 1px dashed rgba(0, 242, 254, 0.28);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.45);
  color: var(--text-muted, #94a3b8);
}
.rb-empty-state i {
  font-size: 2.2rem;
  color: var(--primary, #00f2fe);
  margin-bottom: 10px;
  opacity: 0.85;
}

/* 4. RAILBAN Next Modular Hub */
.next-hub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
.next-tab-btn {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text-main, #f8fafc);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.next-tab-btn:hover {
  border-color: var(--primary, #00f2fe);
  transform: translateY(-1px);
}
.next-tab-btn.active {
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.22), rgba(125, 95, 255, 0.28));
  border-color: var(--primary, #00f2fe);
  color: #fff;
  box-shadow: 0 0 18px rgba(0, 242, 254, 0.22);
}
.next-panel {
  display: none;
}
.next-panel.active {
  display: block;
}
.next-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr));
  gap: 18px;
}
.next-list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
  min-width: 0;
}
.next-list-row > div {
  min-width: 0;
  word-break: break-word;
}
.next-embed-preview {
  background: #2b2d31;
  border-left: 4px solid #00f2fe;
  border-radius: 8px;
  padding: 16px;
  color: #dbdee1;
  font-family: 'Inter', sans-serif;
}
.next-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  background: rgba(0, 242, 254, 0.14);
  color: var(--primary, #00f2fe);
  border: 1px solid rgba(0, 242, 254, 0.3);
}

/* 5. Fix alineación y espaciado en tarjeta "Estado del Motor Local" (AI Station) */
.ai-specs-grid {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
}
.ai-specs-grid .spec-item {
  display: flex !important;
  justify-content: space-between !important;
  align-items: flex-start !important;
  gap: 16px !important;
  padding: 10px 14px !important;
  border-radius: 10px !important;
  background: rgba(255, 255, 255, 0.035) !important;
  border: 1px solid rgba(255, 255, 255, 0.06) !important;
}
.ai-specs-grid .spec-label {
  flex-shrink: 0 !important;
  white-space: nowrap !important;
  font-size: 0.82rem !important;
  color: var(--text-muted, #94a3b8) !important;
  line-height: 1.35 !important;
}
.ai-specs-grid .spec-val {
  text-align: right !important;
  font-size: 0.83rem !important;
  font-weight: 700 !important;
  line-height: 1.35 !important;
  color: var(--primary, #00f2fe) !important;
  word-break: break-word !important;
}
.badge-status-standby {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.badge-status-offline {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.4);
}
.ai-vram-bar-track {
  width: 100%;
  max-width: 190px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.ai-vram-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #00f2fe, #7d5fff);
  transition: width 0.4s ease;
}

/* === VISUAL POLISH: PULSO EN VIVO, SPARKLINE, SAFE-AREA, BACK-TO-TOP & TABULAR NUMS === */
.ai-specs-grid .spec-val,
.next-list-row,
#ai-station-stats-mini {
  font-variant-numeric: tabular-nums;
}
.ai-sidebar-card,
.next-list-row {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
@keyframes rbOnlinePulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}
.badge-status-online {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge-status-online::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  animation: rbOnlinePulse 2.2s infinite;
}
.ai-temp-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  background: rgba(56, 189, 248, 0.14);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  margin-left: 6px;
}
.ai-vram-bar-fill.warn { background: linear-gradient(90deg, #f59e0b, #fbbf24) !important; }
.ai-vram-bar-fill.crit { background: linear-gradient(90deg, #ef4444, #f97316) !important; }

/* Botón flotante Volver Arriba en vistas largas */
.rb-back-to-top {
  position: fixed;
  right: 18px;
  bottom: calc(82px + env(safe-area-inset-bottom, 0px));
  z-index: 44000;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(0, 242, 254, 0.4);
  background: rgba(10, 15, 30, 0.88);
  color: #00f2fe;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}
.rb-back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.rb-mini-player {
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}
.btn:active,
.gi-char-chip:active,
.next-tab-btn:active {
  transform: scale(0.97) !important;
}
:focus-visible {
  outline: 2px solid #00f2fe !important;
  outline-offset: 2px;
}

/* === MAIN WEBSITE VISUAL POLISH: AURORA, SHIMMER CTA, BENTO, SCROLL-REVEAL, TOOLTIPS & RESPONSIVE === */
#landing-page {
  position: relative;
  background-image:
    radial-gradient(ellipse 68% 42% at 50% -6%, rgba(0, 242, 254, 0.08), transparent 62%),
    radial-gradient(ellipse 52% 36% at 84% 12%, rgba(125, 95, 255, 0.07), transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.024) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.024) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 42px 42px, 42px 42px;
}

/* Navbar scroll elevation & active link glow */
nav.scrolled,
header.scrolled {
  backdrop-filter: blur(22px) saturate(150%) !important;
  -webkit-backdrop-filter: blur(22px) saturate(150%) !important;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45) !important;
}
#unified-nav-links a.active {
  position: relative;
  color: var(--primary, #00f2fe) !important;
}
#unified-nav-links a.active::after {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: -4px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #00f2fe, transparent);
}

/* CTA Primary Shimmer Sweep */
.btn-primary {
  position: relative;
  overflow: hidden;
}
.btn-primary::after {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 65%;
  height: 100%;
  background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transition: left 0.55s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}
.btn-primary:hover::after {
  left: 135%;
}

/* Specular highlight & hover lift on all glass cards */
.glass-card,
.feature-card,
.card.glass {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 30px rgba(0, 0, 0, 0.3);
  transition: transform 0.26s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.26s ease, box-shadow 0.26s ease;
}
#features .glass-card:hover,
#features .feature-card:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 242, 254, 0.42);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 16px 38px rgba(0, 242, 254, 0.14);
}

/* Scroll-reveal animations */
.rb-reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}
.rb-reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* Page transition */
@keyframes rbPageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-content[style*="display: block"] {
  animation: rbPageIn 0.24s ease;
}

/* AI Station: burbujas, barras VRAM segmentadas, prompts swipeables */
.ai-vram-bar-track {
  background-image: repeating-linear-gradient(90deg, rgba(255,255,255,0.08) 0 24%, rgba(0,0,0,0.35) 24% 25%);
}
.ai-station-prompts-bar {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.ai-station-prompts-bar::-webkit-scrollbar { display: none; }
.ai-station-chip { scroll-snap-align: start; flex-shrink: 0; }

/* Mini-Player barra de progreso superior & colapso móvil */
.rb-mini-progress {
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}
.rb-mini-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #00f2fe, #7d5fff);
  transition: width 0.9s linear;
}
.rb-mini-player.collapsed {
  width: auto !important;
  max-width: none !important;
  padding: 8px 12px !important;
  border-radius: 999px !important;
}
.rb-mini-player.collapsed .rb-mini-info,
.rb-mini-player.collapsed .rb-mini-progress {
  display: none !important;
}

/* Hover sutil en filas clicables */
.next-list-row {
  transition: transform 0.18s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.next-list-row:hover {
  border-color: rgba(0, 242, 254, 0.34);
  background: rgba(0, 242, 254, 0.06);
}

/* Tipografía fluida & tabular nums globales */
#landing-page h1 { font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1.12; }
#landing-page h2 { font-size: clamp(1.45rem, 3.2vw, 2.25rem); }
.hero-stat-num, .stat-value, .stat-number { font-variant-numeric: tabular-nums; }

/* Footer separator glow */
footer {
  position: relative;
}
footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 242, 254, 0.45), transparent);
}

/* Custom CSS Tooltips */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 9px;
  border-radius: 7px;
  background: rgba(5, 8, 20, 0.95);
  border: 1px solid rgba(0, 242, 254, 0.4);
  color: #f8fafc;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  z-index: 60000;
  pointer-events: none;
}

@media (max-width: 600px) {
  .hero-actions, .cta-group {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }
  .hero-actions .btn, .cta-group .btn {
    width: 100%;
    min-height: 46px;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rb-reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
  .btn-primary::after, .badge-status-online::before { animation: none !important; transition: none !important; }
}

/* === GUARD GLOBAL ANTI-OVERFLOW & RESPONSIVE AI STATION / MODALES / NEXT HUB === */
html, body {
  overflow-x: clip !important;
  max-width: 100% !important;
}
.next-hub-wrapper,
.ai-station-wrapper,
.ai-station-grid,
.ai-station-sidebar,
.ai-sidebar-card {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 960px) {
  .ai-station-grid {
    grid-template-columns: 1fr !important;
  }
  .ai-station-console {
    height: min(68vh, 520px) !important;
  }
}

@media (max-width: 767px) {
  .next-hub-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
  }
  .next-hub-tabs .next-tab-btn {
    flex-shrink: 0;
    min-height: 44px;
    scroll-snap-align: start;
  }
  .next-grid-2 {
    grid-template-columns: 1fr;
  }
  .rb-mini-player {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
  }
  .modal-content,
  .modal-box,
  .glass-modal {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
    margin: 12px auto !important;
  }
}

@media (max-width: 460px) {
  .ai-specs-grid .spec-item {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }
  .ai-specs-grid .spec-val {
    text-align: left !important;
  }
  .ai-vram-bar-track {
    max-width: 100% !important;
  }
  .glass-card {
    padding: 16px;
  }
}
