/* =====================================================
   IOSoccer SA — SIDEBAR LAYOUT & ANIMATIONS
   ===================================================== */

:root {
  --sidebar-width: 224px;
  --sidebar-bg: rgba(8, 8, 8, 0.99);
  --sidebar-border: rgba(255, 120, 0, 0.1);
  --accent: #ff7800;
  --accent-dim: rgba(255, 120, 0, 0.1);
  --anim-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --anim-ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── Layout root ── */
body {
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ══════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════ */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 120, 0, 0.12) transparent;
  animation: sidebar-slide-in 0.46s var(--anim-spring) both;
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 120, 0, 0.18);
  border-radius: 3px;
}

@keyframes sidebar-slide-in {
  from { transform: translateX(-100%); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

/* ── Header / Logo ── */
.sidebar-header {
  padding: 1.2rem 1rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  transition: opacity 0.2s;
}
.sidebar-logo-link:hover { opacity: 0.75; }

.sidebar-logo-img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 7px;
  filter: drop-shadow(0 0 8px rgba(255, 120, 0, 0.2));
  animation: logo-pop 0.5s 0.22s var(--anim-spring) both;
  flex-shrink: 0;
}

@keyframes logo-pop {
  from { transform: scale(0.6) rotate(-8deg); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.sidebar-brand-name {
  font-size: 0.88rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.01em;
  line-height: 1.1;
  white-space: nowrap;
}

.sidebar-brand-sub {
  font-size: 0.58rem;
  color: var(--accent);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  line-height: 1;
}

/* ── Navigation ── */
.sidebar-nav {
  flex: 1;
  padding: 0.5rem 0;
  overflow: visible;
}

/* Defensive reset against residual inline nav CSS */
.sidebar-nav ul {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.04rem;
  overflow: visible !important;
}

.sidebar-nav li {
  flex: none !important;
  display: block !important;
}

/* Nav links */
.sidebar-nav a {
  display: flex !important;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.85rem 0.6rem 1rem !important;
  margin: 0 0.4rem;
  color: #666;
  text-decoration: none !important;
  font-size: 0.835rem !important;
  font-weight: 500;
  border-radius: 8px;
  white-space: nowrap;
  position: relative;
  transition:
    color      0.18s var(--anim-ease),
    background 0.18s var(--anim-ease),
    box-shadow 0.18s var(--anim-ease);
  animation: nav-item-in 0.42s var(--anim-spring) both;
  box-sizing: border-box;
}

/* Stagger entrance */
.sidebar-nav li:nth-child(1) a { animation-delay: 0.06s; }
.sidebar-nav li:nth-child(2) a { animation-delay: 0.10s; }
.sidebar-nav li:nth-child(3) a { animation-delay: 0.14s; }
.sidebar-nav li:nth-child(4) a { animation-delay: 0.18s; }
.sidebar-nav li:nth-child(5) a { animation-delay: 0.22s; }
.sidebar-nav li:nth-child(6) a { animation-delay: 0.26s; }
.sidebar-nav li:nth-child(7) a { animation-delay: 0.30s; }
.sidebar-nav li:nth-child(8) a { animation-delay: 0.34s; }
.sidebar-nav li:nth-child(9) a { animation-delay: 0.38s; }

@keyframes nav-item-in {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: none; }
}

/* Hover */
.sidebar-nav a:hover {
  color: #ccc;
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-nav a:hover .nav-icon {
  color: var(--accent);
  transform: scale(1.1);
}

/* ── Active state ── clean, no animation conflicts */
.sidebar-nav a.active {
  color: var(--accent) !important;
  background: var(--accent-dim) !important;
  font-weight: 600;
  box-shadow: inset 3px 0 0 0 var(--accent);
  animation: nav-item-in 0.42s var(--anim-spring) both;
}

.sidebar-nav a.active .nav-icon {
  color: var(--accent);
  filter: drop-shadow(0 0 5px rgba(255, 120, 0, 0.35));
}

/* Icons */
.nav-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: #3e3e3e;
  transition:
    color     0.18s var(--anim-ease),
    transform 0.18s var(--anim-spring),
    filter    0.18s;
}

/* ── Sidebar footer ── */
.sidebar-footer {
  padding: 0.85rem 1rem 1.1rem;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-footer-text {
  font-size: 0.63rem;
  color: #2a2a2a;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

.sidebar-footer a {
  color: #333;
  text-decoration: none;
  transition: color 0.2s;
}
.sidebar-footer a:hover { color: var(--accent); }

/* ══════════════════════════════════════════
   MAIN CONTENT WRAPPER
   ══════════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  animation: content-enter 0.42s 0.15s var(--anim-spring) both;
}

@keyframes content-enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ══════════════════════════════════════════
   MOBILE TOPBAR
   ══════════════════════════════════════════ */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1rem;
  background: rgba(8, 8, 8, 0.99);
  border-bottom: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  z-index: 150;
}

.mobile-topbar-logo-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.mobile-topbar-img {
  height: 24px;
  width: auto;
  flex-shrink: 0;
}

.mobile-topbar-brand {
  font-size: 0.8rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.01em;
}

.sidebar-toggle-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(255, 120, 0, 0.2);
  border-radius: 7px;
  width: 34px;
  height: 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.18s, border-color 0.18s;
}

.sidebar-toggle-btn:hover {
  background: rgba(255, 120, 0, 0.1);
  border-color: rgba(255, 120, 0, 0.4);
}

.sidebar-toggle-btn span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: #888;
  border-radius: 2px;
  transition:
    transform  0.26s var(--anim-spring),
    opacity    0.16s,
    background 0.16s;
}

/* Hamburger → X when open */
.sidebar-open .sidebar-toggle-btn span:nth-child(1) {
  transform: translateY(5.5px) rotate(45deg);
  background: var(--accent);
}
.sidebar-open .sidebar-toggle-btn span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.sidebar-open .sidebar-toggle-btn span:nth-child(3) {
  transform: translateY(-5.5px) rotate(-45deg);
  background: var(--accent);
}

/* ── Overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 190;
}

/* ══════════════════════════════════════════
   RESPONSIVE — MOBILE
   ══════════════════════════════════════════ */
@media (max-width: 768px) {
  body { display: block; }

  .sidebar {
    transform: translateX(-100%);
    animation: none;
    transition: transform 0.32s var(--anim-spring), box-shadow 0.32s;
    width: 236px;
    box-shadow: none;
  }

  .sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.7);
  }

  .mobile-topbar {
    display: flex !important;
  }

  .main-content {
    margin-left: 0;
    animation: none;
  }

  .sidebar-overlay.visible {
    display: block;
  }

  /* ── Guardas globales de seguridad móvil ──
     Previenen los problemas más comunes en celular sin tocar el CSS
     propio de cada página. */

  /* 1. Nunca permitir scroll horizontal de toda la página */
  html, body { overflow-x: hidden; max-width: 100%; }
  .main-content { max-width: 100vw; overflow-x: hidden; }

  /* 2. Medios e imágenes nunca desbordan (no afecta íconos SVG inline) */
  .main-content img,
  .main-content video,
  .main-content iframe { max-width: 100%; height: auto; }

  /* 3. Tablas de datos anchas → scroll horizontal propio en vez de
        romper o desbordar el layout */
  .main-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  /* 4. Texto largo (nombres, URLs) puede cortar en vez de desbordar */
  .main-content p,
  .main-content h1,
  .main-content h2,
  .main-content h3 { overflow-wrap: break-word; }
}

/* ══════════════════════════════════════════
   ACCESIBILIDAD
   ══════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-logo-img,
  .sidebar-nav a,
  .main-content {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}
