@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&display=swap');

*{
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Poppins", sans-serif;
}

:root{
  --color-bg: #EBECF2;
  --color-surface: #FFFFFF;
  --color-border: #9A9EB2;
  --color-text-primary: #000;
  --color-text-secondary: #3F435D;
  --color-tooltip-bg: #2A2E33;
  --color-tooltip-text: #fff;
  --shadow-border: rgba(0, 0, 0, 0.1);
  --user-bg-color: #FAFAFC;

  /* Layout */
  --sidebar-w: 15rem;
  --sidebar-w-min: 4.94rem;
  --topbar-h: 64px;
}

body.dark-mode{
  --color-bg: #3A3D4D;
  --color-surface: #12141A;
  --color-border: #2B2D3B;
  --color-text-primary: #FFFFFF;
  --color-text-secondary: #9CA2B8;
  --color-tooltip-bg: #fff;
  --color-tooltip-text: #000;
  --shadow-border: rgba(255, 255, 255, 0.1);
  --user-bg-color: #FAFAFC;
}

/* Body */
body{
  display: flex;
  width: 100%;
  height: 100vh;
  background-color: var(--color-bg);
  transition: color 0.5s ease, background-color 0.3s ease, left 0.5s ease;
}

/* Sidebar */
.sidebar{
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: var(--sidebar-w);
  height: 100%;
  padding: 1.4rem 1rem 0 1rem;
  background-color: var(--color-surface);
  box-shadow: 1px 0px 10px var(--shadow-border);
  transition: width 0.5s ease, transform 0.3s ease;
  z-index: 40;
}

.sidebar.minimize{
  width: var(--sidebar-w-min);
}

/* Header */
.header{
  width: 100%;
}

/* Menu Button */
.menu-btn{
  position: absolute;
  top: 3.5%;
  right: -0.87rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background-color: #fff;
  color: #757575;
  box-shadow: 2px 2px 5px var(--shadow-border);
  cursor: pointer;
  transition: right 0.3s ease;
}

.menu-btn i{
  font-size: 1.5rem;
}

.sidebar.minimize .menu-btn{
  right: -2.2rem;
}

.sidebar.minimize .menu-btn i{
  transform: rotate(180deg);
}

/* Brand */
.brand{
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding-left: 0.455rem;
  margin-bottom: 1.8rem;
  overflow: hidden;
}

.brand img{
  width: 2rem;
}

.brand span{
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

/* Menu Container */
.menu-container{
  display: flex;
  width: 100%;
  height: 100%;
  flex-direction: column;
  align-items: center;
}

/* Search */
.search{
  display: flex;
  width: 100%;
  padding: 0.55rem 0;
  margin-bottom: 1.2rem;
  border-radius: 0.3rem;
  box-shadow: 0 0 0 1px var(--color-border);
  cursor: pointer;
  transition: box-shadow 0.5s ease;
}

.search:hover{
  box-shadow: 0 0 0 1px var(--color-text-primary);
}

.sidebar.minimize .search{
  box-shadow: none;
}

.sidebar.minimize .search:hover{
  background-color: var(--color-bg);
}

.search i{
  font-size: 1.35rem;
  color: var(--color-text-secondary);
  padding: 0 0.8rem;
}

.search:hover i{
  color: var(--color-text-primary);
}

.search input{
  width: 70%;
  border: none;
  outline: none;
  background-color: transparent;
  color: var(--color-text-primary);
}

/* Menu */
.menu{
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.menu .menu-item{
  position: relative;
  list-style: none;
  overflow: hidden;
}

.menu .menu-link{
  display: flex;
  padding: 0.55rem 0;
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: 0.3rem;
}

.menu-item:hover .menu-link,
.sub-menu .sub-menu-link:hover,
.menu-item.active .menu-link{
  color: var(--color-text-primary);
  background-color: var(--color-bg);
}

.menu-link i{
  font-size: 1.35rem;
  padding: 0 0.8rem;
}

.menu-link i:last-child{
  margin-left: auto;
  transition: transform 0.3s ease;
}

.sidebar.minimize .menu-link i:last-child{
  display: none;
}

.menu-item.sub-menu-toggle .menu-link i:last-child{
  transform: rotate(180deg);
}

.menu-link span{
  font-size: 0.8rem;
  font-weight: 500;
}

.sidebar.minimize .menu-item:hover,
.sidebar.minimize .menu-item.sub-menu-toggle{
  overflow: visible;
}

.sidebar.minimize .menu-item:hover span,
.sidebar.minimize .menu-item.sub-menu-toggle span{
  position: absolute;
  left: 4.2rem;
  padding: 0.5rem;
  background-color: var(--color-tooltip-bg);
  border-radius: 0.4rem;
  color: var(--color-tooltip-text);
  transition: all 0.3s ease;
}

/* Sub menu */
.sub-menu{
  height: 0;
  transition: all 0.3s ease;
  overflow: hidden;
  left: 0;
}

.sidebar.minimize .sub-menu{
  position: absolute;
  left: 4.2rem;
  top: 3rem;
  background-color: var(--color-surface);
  border-radius: 0.2rem;
}

.sub-menu .sub-menu-link{
  display: flex;
  margin-left: 2.5rem;
  padding: 0.55rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  border-radius: 0.3rem;
}

.sub-menu::before{
  content: '';
  position: absolute;
  height: 100%;
  width: 0.07rem;
  margin-left: 1.4rem;
  background-color: var(--color-border);
}

.sidebar.minimize .sub-menu::before{
  width: 0;
}

.sidebar.minimize .sub-menu a{
  margin: 0 0.5rem;
}

/* Footer */
.footer{
  width: 100%;
  padding: 1rem 0;
  box-shadow: 0 -0.02rem 0 0 var(--color-border);
}

.user{
  display: flex;
  overflow: hidden;
  margin-top: 1rem;
}

.user-img{
  display: flex;
  margin: 0 0.7rem 0 0.35rem;
}

.user-img img{
  width: 2.2rem;
  height: 2.2rem;
  object-fit: cover;
  border-radius: 50%;
}

.user-data{
  display: flex;
  flex-direction: column;
  overflow: hidden;
  white-space: nowrap;
}

.user-data .name{
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.user-data .email{
  font-size: 0.7rem;
  color: var(--color-text-secondary);
}

.user-icon{
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--color-text-secondary);
}

/* Sidebar button (móvil) */
.sidebar-btn{
  display: none;
}

/* ===== NAVBAR TOP ===== */
.topbar{
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--color-surface);
  box-shadow: 0 1px 10px var(--shadow-border);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  transition: left 0.5s ease;
}

/* cuando sidebar minimiza, navbar se corre */
.sidebar.minimize ~ .topbar{
  left: var(--sidebar-w-min);
}

.topbar-left{
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-title{
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.topbar-h1{
  font-weight: 800;
  color: var(--color-text-primary);
}

.topbar-h2{
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.topbar-right{
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.6rem;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  text-decoration: none;
}

.topbar-icon i{
  font-size: 1.45rem;
}

.topbar-icon:hover{
  background: var(--color-bg);
  color: var(--color-text-primary);
}

.topbar-search{
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.6rem;
  box-shadow: 0 0 0 1px var(--color-border);
}

.topbar-search i{
  font-size: 1.2rem;
  color: var(--color-text-secondary);
}

.topbar-search input{
  border: none;
  outline: none;
  background: transparent;
  color: var(--color-text-primary);
  width: 220px;
}

/* ===== MAIN ===== */
main{
  padding: calc(var(--topbar-h) + 1.25rem) 3rem 3rem 17rem; /* top right bottom left */
  transition: padding 0.5s ease;
}

main h1{
  color: var(--color-text-primary);
}

/* IMPORTANTE: ahora es ~ (porque nav está entre sidebar y main) */
.sidebar.minimize ~ main{
  padding-left: 7.96rem;
}

/* Dark mode (logos) */
.brand-dark{
  display: none;
}

body.dark-mode .brand-dark{
  display: flex;
}

body.dark-mode .brand-light{
  display: none;
}

/* Dark mode button */
.dark-mode-btn{
  position: absolute;
  width: 2.4rem;
  height: 2.4rem;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #fff;
  border-radius: 50%;
  box-shadow: 0 0 10px 2px var(--shadow-border);
  cursor: pointer;
  overflow: hidden;
  z-index: 50;
}

.dark-mode-btn i{
  font-size: 1.5rem;
  position: absolute;
  transition: transform 0.3s ease-in;
}

.dark-mode-btn i:last-child{
  transform: translateY(150%);
}

body.dark-mode .dark-mode-btn i:last-child{
  transform: translateY(0%);
}

body.dark-mode .dark-mode-btn i:first-child{
  transform: translateY(-150%);
}

/* Responsive */
@media (max-height: 683px){
  .footer{
    box-shadow: none;
  }
  .footer ul{
    display: none;
  }
  .menu-container{
    overflow-y: auto;
  }
  .search{
    box-shadow: none;
    border: 2px solid var(--color-border);
  }
  .search:hover{
    box-shadow: none;
  }
  main{
    padding: calc(var(--topbar-h) + 1.25rem) 2rem 2rem 2rem;
  }
}

/* Mobile */
@media (max-width:700px) or (max-height:683px){
  #menu-btn{
    display: none;
  }

  .sidebar{
    transform: translateX(-100%);
  }

  .sidebar-btn{
    display: flex;
    right: 1rem;
    padding: 1.2rem;
  }

  .sidebar-btn i:last-child{
    display: none;
  }

  body.sidebar-hidden .sidebar{
    transform: translateX(0);
  }

  body.sidebar-hidden .sidebar-btn i:last-child{
    display: flex;
  }

  body.sidebar-hidden .sidebar-btn i:first-child{
    display: none;
  }

  /* navbar en móvil ocupa todo */
  .topbar{
    left: 0;
  }

  main{
    padding: calc(var(--topbar-h) + 1.25rem) 2rem 2rem 2rem;
  }
}

/* === NO duplicar botones === */
.dark-mode-btn{ display: none !important; }
.sidebar-btn{ display: none !important; }

/* === Botón luna/sol dentro del navbar === */
.topbar-dark{
  position: relative;
  overflow: hidden;
}
.topbar-dark i{
  position: absolute;
  transition: transform 0.3s ease-in;
}
.topbar-dark i:last-child{
  transform: translateY(150%);
}
body.dark-mode .topbar-dark i:last-child{
  transform: translateY(0%);
}
body.dark-mode .topbar-dark i:first-child{
  transform: translateY(-150%);
}

/* === Botón sidebar SOLO móvil === */
.topbar-mobile{
  display: none;
}
.topbar-mobile i:last-child{
  display: none;
}
body.sidebar-hidden .topbar-mobile i:last-child{
  display: inline-block;
}
body.sidebar-hidden .topbar-mobile i:first-child{
  display: none;
}

@media (max-width:700px) or (max-height:683px){
  .topbar-mobile{
    display: inline-flex;
  }
}



/* En PC, al no haber texto a la izquierda, alineamos mejor */
@media (min-width:701px) and (min-height:684px){
  .topbar-left{ min-width: 1px; }
}

/* ===== FIX logo NAVBAR (evita que se agrande por .brand-dark global) ===== */
.topbar-brand{
  display: none;              /* solo móvil */
  align-items: center;
  gap: .55rem;
  text-decoration: none;
  color: var(--color-text-primary);
  font-weight: 700;
  line-height: 1;
}

/* tamaño fijo del logo en navbar */
.topbar-brand img{
  width: 28px !important;
  height: 28px !important;
  object-fit: contain;
  display: inline-block !important; /* evita display:flex que lo rompe */
}

/* controla light/dark SOLO dentro del navbar */
.topbar-brand .brand-dark{ display: none !important; }
.topbar-brand .brand-light{ display: inline-block !important; }
body.dark-mode .topbar-brand .brand-dark{ display: inline-block !important; }
body.dark-mode .topbar-brand .brand-light{ display: none !important; }

/* mostrar logo solo en móvil */
@media (max-width:700px) or (max-height:683px){
  .topbar-brand{ display: inline-flex; }
}

/* ✅ FIX: que el contenido (main) ocupe todo el ancho disponible */
main{
  flex: 1;        /* toma el espacio restante del body:flex */
  width: 100%;
  min-width: 0;   /* evita overflow raro en grid */
}






