/* Sidebar styles - consolidated and cleaned
   - Smooth width animation on the container
   - Icons visible when collapsed
   - Labels animate opacity/translate with stagger for a soft entrance
   - Reduced motion respected
*/

:root{ --sidebar-bg: #213362; --pin-color: #FFCD00; --sidebar-collapsed-w: 64px; --sidebar-expanded-w: 16rem; }

html, body { overflow-x: hidden; }

/* ---- Sidebar brand header ---- */
.sidebar-brand {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid rgba(255, 205, 0, 0.18);
}
.sidebar-brand-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.sidebar-brand-header .pin-btn {
  margin-left: auto;
  width: auto;
  padding: 4px 5px;
  flex-shrink: 0;
  border-radius: 5px;
}
.sidebar-brand-icon {
  color: #FFCD00;
  font-size: 20px !important;
  flex-shrink: 0;
  opacity: 0.9;
}
.sidebar-brand-title {
  color: #FFCD00;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.sidebar-brand-sub {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.sidebar-brand-sub--btm {
  padding: 0.5rem 0.25rem;
  border-bottom: 1px solid rgba(255, 205, 0, 0.15);
  margin-bottom: 0;
}
.sidebar-brand-sub span {
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.67rem;
  font-weight: 400;
  line-height: 1.35;
}
.sidebar-brand-year {
  color: rgba(255, 255, 255, 0.88) !important;
  font-weight: 700 !important;
  font-size: 0.71rem !important;
}
/* Cuando el sidebar está colapsado, ocultar también el brand sub */
.sidebar.collapsed .sidebar-brand-sub { display: none; }
.sidebar.collapsed .sidebar-brand-title { display: none; }

.sidebar{
  background-color: var(--sidebar-bg);
  position: fixed; /* fixed so it stays visible while the page scrolls */
  left: 0;
  top: 0;
  z-index: 9999; /* ensure sidebar stays above main content when main creates a stacking context */
  height:100vh;
  width: var(--sidebar-width, var(--sidebar-collapsed-w));
  min-width: var(--sidebar-width, var(--sidebar-collapsed-w));
  display:flex;
  flex-direction:column;
  /* Contener layout/pintura para reducir el costo durante animaciones */
  contain: layout paint;
  /* keep width transition but use a gentler easing for a softer feel */
  transition: width 200ms cubic-bezier(.25,.8,.25,1), box-shadow 180ms cubic-bezier(.25,.8,.25,1), opacity 160ms ease;
  will-change: width, box-shadow, opacity;
  overflow:visible;
  flex-shrink:0;
  transform-origin: left center;
}
.sidebar{ overflow-x: hidden; }
.sidebar.expanded{ 
  width: var(--sidebar-expanded-w); 
  /* slightly reduced shadow so expansion feels lighter */
  box-shadow: 0 6px 18px rgba(15,23,42,0.12); 
  opacity: 1;
}

/* Header area */
.sidebar > .p-6{ padding: 1.25rem; }
.sidebar .menu-title{ display:block; transition: opacity 140ms ease, transform 140ms ease; }

/* Nav area */
.sidebar nav{ flex:1 1 auto; overflow-y:auto; overflow-x:hidden; padding-bottom:0; -webkit-overflow-scrolling: touch; }
.sidebar nav{ -ms-overflow-style: none; scrollbar-width: none; }
.sidebar nav::-webkit-scrollbar{ width: 0; height: 0; }
.sidebar nav ul{ display:flex; flex-direction:column; gap:1rem; margin:0; padding:0.5rem; list-style:none; }
.sidebar nav ul li{ border-radius:8px; }
.idebug-hidden{ display:none !important; }
.sidebar nav ul li a{ 
  display:flex; 
  align-items:center; 
  gap:1rem; 
  padding:0.6rem 0.75rem; 
  color:inherit; 
  min-height:48px;
  border-radius: 8px;
  /* slightly shorter transform timing and gentler easing for link hover */
  transition: background-color 180ms cubic-bezier(.22,.9,.3,1), color 180ms ease, transform 180ms cubic-bezier(.22,.9,.3,1);
  will-change: transform, background-color, color;
  position: relative;
  overflow: hidden;
}
.sidebar nav ul li a{ width:100%; box-sizing:border-box; }

/* Hover effects */
.sidebar nav ul li a:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #f3f4f6;
  /* smaller nudge on hover for a subtler feel */
  transform: translateX(2px);
}
.sidebar nav ul li a:hover .material-icons {
  color: #00AEE3;
  /* reduced icon scale to keep motion subtle */
  transform: scale(1.04);
  transition: color 180ms ease, transform 160ms cubic-bezier(.22,.9,.3,1);
}

/* Active item styling */
.sidebar nav ul li.bg-gray-700 a { background: linear-gradient(135deg, #07519D 0%, #00AEE3 100%); color: white; box-shadow: 0 2px 8px rgba(7,81,157,0.3); }
.sidebar nav ul li.bg-gray-700 a .material-icons { color: #FFCD00; }

/* Collapsed layout: center icons */
.sidebar.collapsed nav{ overflow:visible; }
.sidebar.collapsed nav ul li a{ justify-content:center; padding-left:0; padding-right:0; }
.sidebar.collapsed nav ul li{ padding-left:0; padding-right:0; }
.sidebar.collapsed nav ul li a:hover { transform: none; }

/* Labels */
.sidebar .menu-label{ display:inline-block; transition: opacity 260ms cubic-bezier(.25,.8,.25,1), transform 260ms cubic-bezier(.25,.8,.25,1); transform-origin: left center; opacity:1; transform: translateX(0); }
.sidebar.collapsed .menu-label{ opacity:0; transform: translateX(-4px) scale(0.985); width:0; margin:0; pointer-events:none; transition: opacity 140ms ease-in, transform 200ms cubic-bezier(.36,.06,.23,.94); }
.sidebar.expanded .menu-label{ opacity:1; transform: translateX(0); }
.sidebar.collapsed .menu-title{ display:none; }

/* Bottom area */
.sidebar .bottom-area{ width:100%; padding:1rem; display:flex; flex-direction:column; align-items:stretch; gap:0.5rem; }
.sidebar.collapsed .bottom-area a{ justify-content:center; padding-left:0; padding-right:0; }

/* Logout button */
.logout-danger { background: #6C7175; color: #fff; border: none; padding: 10px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; width: 100%; box-sizing: border-box; gap: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-danger:hover { background: #4b5563; }
.logout-danger .material-icons { font-size: 18px; }
.auth-login-cta,
.login-cta { background: #FFCD00; color: #111827; border: none; padding: 10px 12px; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; width: 100%; box-sizing: border-box; gap: 10px; font-weight: 700; box-shadow: 0 8px 24px -14px rgba(255, 205, 0, 0.75); transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-login-cta:hover,
.login-cta:hover { filter: brightness(0.97); transform: translateY(-1px); box-shadow: 0 12px 24px -14px rgba(255, 205, 0, 0.85); }
.auth-login-cta .material-icons,
.login-cta .material-icons { font-size: 18px; }
.sidebar.collapsed .logout-danger { width: 44px; padding-left: 6px; padding-right: 6px; justify-content: center; }
.sidebar.collapsed .logout-danger .menu-label { display: none !important; }
.sidebar.collapsed .auth-login-cta,
.sidebar.collapsed .login-cta { width: 44px; padding-left: 6px; padding-right: 6px; justify-content: center; }
.sidebar.collapsed .auth-login-cta .menu-label,
.sidebar.collapsed .login-cta .menu-label { display: none !important; }

/* Bottom area expanded behavior */
.sidebar.expanded .bottom-area { flex-direction:column !important; align-items:stretch !important; }
.sidebar.expanded .bottom-area .logout-danger { width:100%; justify-content:flex-start; padding-left:12px; }
.sidebar.expanded .bottom-area .auth-login-cta,
.sidebar.expanded .bottom-area .login-cta { width:100%; justify-content:flex-start; padding-left:12px; }

/* Pin button visuals */
.pin-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.5);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity .15s ease, transform .15s ease, background 160ms ease, color 160ms ease;
}
.pin-btn .material-icons { font-size: 16px; flex-shrink: 0; }
.pin-btn:hover { background: rgba(255,255,255,0.1); color: rgba(255,255,255,0.8); }
.pin-btn.pinned { color: var(--pin-color); border-color: rgba(255,205,0,0.3); background: rgba(255,205,0,0.08); }
.pin-btn.pinned:hover { background: rgba(255,205,0,0.14); }
.sidebar.collapsed .pin-btn { display: none !important; }
.sidebar:focus-within .pin-btn, .sidebar.expanded .pin-btn, .pin-btn.pinned, .pin-btn.force-visible { opacity:1; pointer-events:auto; transform:translateY(0); transition: opacity 200ms ease, transform 200ms cubic-bezier(.2,.9,.2,1), background 160ms ease, color 160ms ease; }

/* Helpers */
.sidebar li.bg-gray-700{ background: transparent !important; }
.sidebar li.text-white{ color:#fff !important; }

@media (prefers-reduced-motion:reduce){ .sidebar, .pin-btn{ transition:none !important; } }

/* Icons */
.sidebar nav ul li a .material-icons{ display:block; font-size:24px; line-height:24px; transition: transform 150ms ease, color 180ms ease; }
.sidebar.collapsed nav ul li a .material-icons{ display:block; font-size:24px; line-height:24px; }
.sidebar.collapsed nav ul li a .menu-label{ display:none !important; }

/* Collapsed overrides */
.sidebar.collapsed{ overflow:hidden !important; }
.sidebar.collapsed .menu-label{ display:none !important; opacity:0 !important; max-width:0 !important; width:0 !important; margin:0 !important; padding:0 !important }
.sidebar.collapsed .bottom-area{ padding-left:6px; padding-right:6px; box-sizing:border-box; overflow:hidden }
.sidebar.collapsed .bottom-area .logout-danger{ max-width:100%; padding-left:6px; padding-right:6px; box-sizing:border-box }
.sidebar .bottom-area a, .sidebar .bottom-area .pin-btn{ flex:0 0 auto }
.sidebar.collapsed .bottom-area{ align-items:center; }
.sidebar.collapsed .bottom-area a{ justify-content:center; width:100%; display:inline-flex; align-items:center; padding-left:0.5rem; padding-right:0.5rem; }
.sidebar.collapsed .bottom-area a .material-icons{ font-size:24px; line-height:24px }
.sidebar.collapsed .bottom-area > div:first-child{ width:100%; justify-content:center; }
.sidebar.collapsed .bottom-area .pin-btn{ width:0; padding:0; margin:0; }
.sidebar.collapsed .bottom-area > div:last-child{ display:none; }

/* Sidebar inner wrapper (structural only) */
.sidebar .sidebar-inner{ display:flex; flex-direction:column; min-height:100vh; height:100%; }

/* Ensure main content doesn't overlay the sidebar and shifts when sidebar expands */
body.layout-with-sidebar main{ 
  z-index: 0;
  margin-left: var(--sidebar-collapsed-w);
  transition: margin-left 260ms cubic-bezier(.25,.8,.25,1);
}

/* When sidebar is expanded, push main content to the right */
body.sidebar-expanded.layout-with-sidebar main {
  margin-left: var(--sidebar-expanded-w);
}

/* Staggered label delays for smoother entrance */
.sidebar.expanded nav ul li:nth-child(1) .menu-label { transition-delay: 40ms; }
.sidebar.expanded nav ul li:nth-child(2) .menu-label { transition-delay: 70ms; }
.sidebar.expanded nav ul li:nth-child(3) .menu-label { transition-delay: 100ms; }
.sidebar.expanded nav ul li:nth-child(4) .menu-label { transition-delay: 130ms; }
.sidebar.expanded nav ul li:nth-child(5) .menu-label { transition-delay: 160ms; }
.sidebar.expanded nav ul li:nth-child(6) .menu-label { transition-delay: 190ms; }

.logout-danger .material-icons {
  font-size: 18px;
}

.sidebar.collapsed .logout-danger {
    width: 44px;
    padding-left: 6px;
    padding-right: 6px;
    justify-content: center;
}

.sidebar.collapsed .logout-danger .menu-label {
    display: none !important;
}

/* Active item helper used by JS - remove gray background, keep only the gradient on the link */
.sidebar li.bg-gray-700{ background: transparent !important; }
.sidebar li.text-white{ color:#fff !important; }

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion:reduce){
  .sidebar, .pin-btn{ transition:none !important; }
}

/* Make icons visually centered when sidebar is collapsed */
.sidebar nav ul li a .material-icons{ 
  display:block; 
  font-size:24px; 
  line-height:24px;
  transition: transform 150ms ease, color 180ms ease;
}
.sidebar.collapsed nav ul li a .material-icons{ 
  display:block; 
  font-size:24px; 
  line-height:24px; 
}
.sidebar.collapsed nav ul li a .menu-label{ display:none !important; }

/* Override: ensure collapsed sidebar clips any overflowing children and hides labels */
.sidebar.collapsed{ overflow:hidden !important; }
.sidebar.collapsed .menu-label{ display:none !important; opacity:0 !important; max-width:0 !important; width:0 !important; margin:0 !important; padding:0 !important }
.sidebar.collapsed .bottom-area{ padding-left:6px; padding-right:6px; box-sizing:border-box; overflow:hidden }
.sidebar.collapsed .bottom-area .logout-danger{ max-width:100%; padding-left:6px; padding-right:6px; box-sizing:border-box }

.sidebar .bottom-area a, .sidebar .bottom-area .pin-btn{ flex:0 0 auto }

/* When collapsed, center settings icon so it lines up with nav icons */
.sidebar.collapsed .bottom-area{ align-items:center; }
.sidebar.collapsed .bottom-area a{ justify-content:center; width:100%; display:inline-flex; align-items:center; }
.sidebar.collapsed .bottom-area a .material-icons{ font-size:24px; line-height:24px }

html.sigma-login-modal-open,
body.sigma-login-modal-open,
html.login-modal-open,
body.login-modal-open {
  overflow: hidden;
}

.sigma-login-modal {
  position: fixed;
  inset: 0;
  z-index: 1000001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.sigma-login-modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.sigma-login-modal__panel {
  position: relative;
  width: min(1080px, 96vw);
  height: min(720px, 92vh);
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: 0 34px 70px -36px rgba(2, 6, 23, 0.95);
  background: #0b1220;
}

.sigma-login-modal__frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: transparent;
}

.sigma-login-modal__close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.64);
  transition: background 150ms ease;
}

.sigma-login-modal__close:hover {
  background: rgba(15, 23, 42, 0.86);
}

body.sigma-login-modal-open .app-loader {
  display: none !important;
}

@media (max-width: 900px) {
  .sigma-login-modal {
    padding: 10px;
  }

  .sigma-login-modal__panel {
    width: 100%;
    height: min(760px, 94vh);
    border-radius: 16px;
  }
}

/* ============================================================
   HAMBURGER BUTTON — visible only on mobile
   ============================================================ */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: inherit;
  flex-shrink: 0;
  transition: background 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
.hamburger-btn:hover  { background: rgba(255,255,255,0.12); }
.hamburger-btn:active { background: rgba(255,255,255,0.2); }
.hamburger-btn .material-icons { font-size: 26px; pointer-events: none; }

/* ============================================================
   SIDEBAR BACKDROP — overlay behind mobile sidebar
   ============================================================ */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.52);
  z-index: 9998;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.sidebar-backdrop.visible { display: block; }

/* ============================================================
   MOBILE RESPONSIVE — max-width: 768px
   ============================================================ */
@media (max-width: 768px) {

  /* Show the hamburger button — styled to match header */
  .hamburger-btn {
    display: inline-flex;
    background: rgba(255,255,255,0.15);
    border: 1.5px solid rgba(255,255,255,0.28);
    color: white;
    border-radius: 10px;
    flex-shrink: 0;
  }
  .hamburger-btn:hover  { background: rgba(255,255,255,0.25); }
  .hamburger-btn:active { background: rgba(255,255,255,0.32); }

  /* Sidebar slides off-screen by default; acts as full-width overlay when open */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 260ms cubic-bezier(0.25, 0.8, 0.25, 1),
                box-shadow 260ms cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    width: var(--sidebar-expanded-w) !important;
    min-width: var(--sidebar-expanded-w) !important;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.45) !important;
  }

  /* When open on mobile, show labels as if expanded */
  .sidebar.mobile-open .menu-label {
    display: inline-block !important;
    opacity: 1 !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
    pointer-events: auto !important;
  }
  .sidebar.mobile-open .sidebar-brand-title { display: block !important; }
  .sidebar.mobile-open .sidebar-brand-sub   { display: flex  !important; }
  .sidebar.mobile-open nav ul li a          { justify-content: flex-start !important; padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
  .sidebar.mobile-open .bottom-area         { align-items: stretch !important; padding-left: 1rem !important; padding-right: 1rem !important; }
  .sidebar.mobile-open .bottom-area .logout-danger,
  .sidebar.mobile-open .bottom-area .auth-login-cta,
  .sidebar.mobile-open .bottom-area .login-cta {
    width: 100% !important;
    justify-content: flex-start !important;
    padding-left: 12px !important;
  }
  .sidebar.mobile-open .bottom-area .menu-label { display: inline !important; }
  .sidebar.mobile-open .pin-btn { display: inline-flex !important; opacity: 1 !important; pointer-events: auto !important; }

  /* Main content uses full width on mobile — no sidebar offset */
  .main-content,
  body.layout-with-sidebar main {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  body.sidebar-expanded .main-content,
  body.sidebar-pinned .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }
}