/* 
   SADE / ENEREY - app.css
   Sidebar SIN animaciones (desktop y mobile)
*/

/* ───────────────────────── RESET / BASE ───────────────────────── */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: #0f172a;
  background: #ffffff;
}

/* ──────────────────────── PALETA ENEREY ──────────────────────── */
:root {
  --enerey-green: #0f5a4f;
  --enerey-green-2: #0b4a41;
  --enerey-green-3: #127464;
  --enerey-gold: #f2b01e;

  --text: #0f172a;
  --muted: rgba(15, 23, 42, .62);
  --border: rgba(15, 23, 42, .10);
  --bg-soft: #f6f8fa;
  --card: #ffffff;
  --shadow: 0 10px 26px rgba(2, 8, 23, .08);

  --sidebar-mini: 60px;
  --sidebar-wide: 276px;

  --radius: 14px;
  --radius-lg: 18px;
}

/* ───────────────────────── APP LAYOUT ───────────────────────── */
.app {
  min-height: 100vh;
  display: flex;
  background: #ffffff;
}

/* =========================================================
   SIDEBAR (DESKTOP) - SIN ANIMACIÓN
   ========================================================= */

.sidebar {
  width: var(--sidebar-wide);
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 20;
  overflow: hidden;

  background: linear-gradient(180deg, var(--enerey-green-2), #063a33);
}


/* No hover effects */
.sidebar:hover {
  width: var(--sidebar-wide) !important;
}

/* Inner fijo */
.sidebar__inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 10px;
  align-items: stretch;
}

/* BRAND */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 56px;
  margin: 0 6px;
  color: #eafffb;
  border-radius: 14px;
}

.brand__logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  display: block;
  border-radius: 10px;
  background: transparent;
}

.brand__text {
  display: inline;
  /* SIEMPRE visible */
  font-weight: 800;
  letter-spacing: .2px;
  white-space: nowrap;
}

.sidebar__divider {
  height: 1px;
  background: rgba(255, 255, 255, .12);
  margin: 4px 10px;
}

/* LABELS */
.sidebar__label,
.nav__section-title {
  display: block;
  /* SIEMPRE visible */
  padding: 6px 12px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: rgba(234, 255, 251, .62);
}

/* NAV */
.nav {
  padding: 0 4px;
  gap: 4px;
}

.nav__section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav__item {
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 10px 10px;
  border-radius: 999px;
  text-decoration: none;

  color: rgba(234, 255, 251, .90);
  border: 1px solid transparent;
  position: relative;
  background: transparent;

  transition: none !important;
  /* no anim */
}

.nav__item:hover {
  background: rgba(255, 255, 255, .07);
}

.nav__item.is-active {
  background: rgba(242, 176, 30, .18);
  border-color: rgba(242, 176, 30, .28);
}

.nav__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav__icon svg {
  width: 15px;
  height: 15px;
}

.nav__text {
  display: inline;
  /* SIEMPRE visible */
  font-size: 13px;
  font-weight: 350;
}

/* BADGE */
.nav__badge {
  display: inline;
  margin-left: auto;
  background: rgba(242, 176, 30, .95);
  color: #08312b;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 850;
}

/* FOOTER */
.nav__bottom {
  margin-top: auto;
  padding: 8px 6px 0;
  border-top: 1px solid rgba(255, 255, 255, .12);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav__button {
  width: 100%;
  background: transparent;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.nav__item.is-danger {
  color: #dd8d8d;
}

.nav__item.is-danger:hover {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.18);
}

/* ───────────────────────── MAIN ───────────────────────── */
.main {
  flex: 1;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main__viewport {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.main__viewport {
  zoom: 1;
}

/* TOPBAR */
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid rgba(15, 23, 42, .08);
}

/* Topbar left: botón + título */
.topbar__left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.page-title {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -.01em;
  color: #0f172a;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* SEARCH */
.search {
  height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;

  width: 280px;
  padding: 0 12px;
  border-radius: 999px;

  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, .10);
}

.search svg,
.search .lucide {
  width: 16px !important;
  height: 16px !important;
  flex: 0 0 auto;
  color: rgba(15, 23, 42, .45);
}

.search__input {
  height: 100%;
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;

  font-size: 13.5px;
  line-height: 36px;
  padding: 0;
  color: #0f172a;
}

.search:focus-within {
  background: #ffffff;
  border-color: rgba(15, 90, 79, 0.35);
  box-shadow: 0 0 0 4px rgba(15, 90, 79, 0.10);
}

.search__input::placeholder {
  color: rgba(15, 23, 42, .45);
}

/* ───────────────────────── USERPILL ───────────────────────── */
.topbar .userpill {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, .10);
  overflow: hidden;
}

.topbar .userpill__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex: 0 0 8px;
}

.topbar .userpill img.userpill__avatar {
  width: 28px !important;
  height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;

  object-fit: cover !important;
  border-radius: 999px !important;

  display: block !important;
  flex: 0 0 28px !important;

  position: static !important;
  inset: auto !important;
  margin: 0 !important;

  border: 1px solid rgba(15, 23, 42, .10);
  background: #fff;
}

/* Dropdown */
.userpill-wrap {
  position: relative;
}

.userpill {
  appearance: none;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, .10);
  cursor: pointer;

  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;

  padding: 0 10px 0 12px;
  border-radius: 999px;
}

.userpill:focus {
  outline: none;
  border-color: rgba(15, 90, 79, 0.35);
  box-shadow: 0 0 0 4px rgba(15, 90, 79, 0.10);
}

.userpill__chev {
  width: 12px;
  height: 12px;
  margin-left: 2px;
  flex: 0 0 12px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 12px;
  opacity: .55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364758b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

.userdrop {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: 320px;
  max-width: 92vw;

  background: #fff;
  border: 1px solid rgba(15, 23, 42, .10);
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(2, 8, 23, .14);

  padding: 12px;
  display: none;
  z-index: 9999;
}

.userdrop.is-open {
  display: block;
}

.userdrop__header {
  padding: 10px 10px 12px;
  border-bottom: 1px solid rgba(15, 23, 42, .08);
}

.userdrop__title {
  font-size: 14px;
  font-weight: 750;
  color: rgba(15, 23, 42, .90);
  line-height: 1.2;
}

.userdrop__sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: rgba(15, 23, 42, .55);
  word-break: break-word;
}

.userdrop__grid {
  padding: 10px 6px 2px;
  display: grid;
  gap: 10px;
}

.userdrop__row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  align-items: start;
}

.userdrop__label {
  font-size: 12px;
  font-weight: 700;
  color: rgba(15, 23, 42, .55);
}

.userdrop__value {
  font-size: 12.5px;
  font-weight: 650;
  color: rgba(15, 23, 42, .82);
  word-break: break-word;
}

/* Neutraliza img globales */
.topbar .userpill img {
  width: 28px !important;
  height: 28px !important;
  max-width: 28px !important;
  max-height: 28px !important;
  object-fit: cover !important;
  border-radius: 999px !important;
  position: static !important;
  inset: auto !important;
  display: block !important;
  flex: 0 0 28px !important;
}

.topbar .userpill .userpill__avatar--fallback {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  flex: 0 0 28px;

  font-size: 12px;
  font-weight: 800;
  color: rgba(15, 23, 42, .75);

  border: 1px solid rgba(15, 23, 42, .10);
  background: #fff;
}

.topbar .userpill__name {
  font-size: 13.5px;
  font-weight: 600;
  color: rgba(15, 23, 42, .72);
  white-space: nowrap;
}

/* ───────────────────────── CONTENT ───────────────────────── */
.content {
  padding: 18px;
  background: #ffffff;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* ───────────────────────── LOGIN (PUBLIC) - AUTH2 FULLSCREEN ───────────────────────── */
body.public {
  background: #ffffff;
  color: var(--text);
}

body.public .public__wrap {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  display: block;
  padding: 0;
  margin: 0;
}

.auth2 select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;

  width: 100%;
  height: 44px;
  padding: 10px 44px 10px 12px;
  border-radius: 14px;

  border: 1px solid rgba(15, 23, 42, .12);
  background-color: #ffffff;
  color: #0f172a;

  font-size: 14px;
  outline: none;

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364758b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}

body.public .auth2 {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;

  background: #ffffff;
  border: 0;
  box-shadow: none;
  border-radius: 0;
}

body.public .auth2__side {
  position: relative;
  width: 100%;
  height: 100%;

  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  color: rgba(234, 255, 251, .96);
  overflow: hidden;
}

body.public .auth2__side::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(6, 58, 51, .52), rgba(6, 58, 51, .82));
  z-index: 0;
}

body.public .auth2__side::after {
  content: "";
  position: absolute;
  inset: -20%;
  background: radial-gradient(60% 60% at 30% 30%, rgba(242, 176, 30, .14), transparent 55%);
  opacity: .85;
  z-index: 0;
}

body.public .auth2__side-inner {
  position: relative;
  z-index: 1;

  height: 100%;
  padding: clamp(28px, 4vw, 56px);
  display: grid;
  place-items: center;
}

body.public .auth2__brand {
  display: flex;
  align-items: center;
  gap: 16px;

  padding: 18px 28px;
  width: min(620px, 92%);
  border-radius: 22px;

  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .22);
  backdrop-filter: blur(10px);
}

body.public .auth2__logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 14px;
  background: transparent;
  border: 0;
  padding: 0;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, .25));
}

body.public .auth2__brandTitle--solo {
  margin: 0;
  font-size: clamp(24px, 2.2vw, 34px);
  font-weight: 900;
  letter-spacing: .3px;
  color: rgba(234, 255, 251, .96);
}

body.public .auth2__main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(26px, 4vw, 72px);
  background: #ffffff;
}

body.public .auth2__card {
  width: 100%;
  max-width: 520px;
}

body.public .auth2__header {
  margin-bottom: 16px;
}

body.public .auth2__title {
  margin: 0;
  font-size: 22px;
  font-weight: 900;
  color: #0f172a;
}

body.public .auth2__subtitle {
  margin: 8px 0 0;
  font-size: 13.5px;
  color: rgba(15, 23, 42, .60);
}

body.public .auth2__error {
  margin: 12px 0 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(220, 38, 38, .22);
  background: rgba(220, 38, 38, .08);
  color: rgba(15, 23, 42, .85);
  font-weight: 650;
}

body.public .auth2__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

body.public .f2 {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body.public .f2__label {
  font-size: 12px;
  font-weight: 750;
  color: rgba(15, 23, 42, .72);
}

body.public input[type="text"],
body.public input[type="password"],
body.public input[type="email"] {
  height: 48px;
  width: 100%;
  padding: 12px 14px;

  border-radius: 16px;
  border: 1px solid rgba(15, 23, 42, .14);
  background: #ffffff;
  color: #0f172a;
  outline: none;
}

body.public input:focus {
  border-color: rgba(15, 90, 79, .45);
  box-shadow: 0 0 0 4px rgba(15, 90, 79, .10);
}

body.public .btn-primary--wide {
  width: 100%;
  height: 48px;
  border-radius: 16px;
  margin-top: 6px;
  background: var(--enerey-green);
  color: #ffffff;
  font-weight: 400;
  cursor: pointer;
}

body.public .btn-primary:hover {
  filter: brightness(0.90);
}

body.public .auth2__footerText {
  display: block;
  margin-top: 18px;
  font-size: 12px;
  color: rgba(15, 23, 42, .55);
}

/* Scroll para tablas grandes */
.table-scroll {
  width: 100%;
  max-height: calc(100vh - 220px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
}

@media (min-width: 861px) and (hover: hover) and (pointer: fine) {

  /* estado base: mini */
  .sidebar {
    width: var(--sidebar-mini);
  }

  /* al hover: expand */
  .sidebar:hover {
    width: var(--sidebar-wide);
  }

  /* BRAND: en mini centramos SOLO el logo, sin cambiar ancho del brand */
  .sidebar .brand {
    width: calc(var(--sidebar-mini) - 20px);
    /* consistente con padding */
    margin: 0 auto;
    justify-content: center;
    gap: 0;
  }

  .sidebar:hover .brand {
    width: auto;
    margin: 0 6px;
    justify-content: flex-start;
    gap: 12px;
  }

  /* ocultar textos en mini */
  .brand__text,
  .nav__text,
  .nav__badge,
  .sidebar__label,
  .nav__section-title {
    display: none;
  }

  /* mostrar textos al expandir */
  .sidebar:hover .brand__text,
  .sidebar:hover .nav__text,
  .sidebar:hover .nav__badge,
  .sidebar:hover .sidebar__label,
  .sidebar:hover .nav__section-title {
    display: inline;
  }

  /* nav items en mini (círculos) */
  .nav__item {
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0 auto;
    border-radius: 50%;
    justify-content: center;
  }

  /* nav items en wide (píldoras) */
  .sidebar:hover .nav__item {
    width: auto;
    height: auto;
    padding: 10px 10px;
    margin: 0;
    border-radius: 999px;
    justify-content: flex-start;
  }
}

/* =========================================================
   MOBILE/TABLET: no uses hover para nada
   ========================================================= */
@media (max-width: 860px) {
  .brand {
    width: auto;
    margin: 0 6px;
    justify-content: flex-start;
    gap: 12px;
  }

  .brand__text,
  .nav__text,
  .nav__badge,
  .sidebar__label,
  .nav__section-title {
    display: inline;
  }
}

/* ───────────────────────── RESPONSIVE ───────────────────────── */
@media (max-width: 980px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   DESKTOP: sidebar colapsado → expandido al hover (RESTAURADO)
   sin cambios de padding ni "brincos"
   ========================================================= */
@media (min-width: 861px) {

  /* Estado normal: mini */
  .sidebar {
    width: var(--sidebar-mini);
  }

  /* Hover: se expande */
  .sidebar:hover {
    width: var(--sidebar-wide);
  }

  /* Inner SIEMPRE igual (evita que se achique/agrande) */
  .sidebar__inner {
    padding: 12px 10px;
    align-items: stretch;
  }


  /* Nav SIEMPRE igual */
  .nav {
    padding: 0;
    gap: 8px;
  }

  /* Items SIEMPRE igual (no cambian con hover) */
  .nav__item {
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0 auto;
    border-radius: 50%;
    justify-content: center;
  }

  /* Textos ocultos en mini */
  .brand__text,
  .nav__text,
  .nav__badge,
  .sidebar__label,
  .nav__section-title {
    display: none;
  }

  /* Textos visibles SOLO cuando se expande */
  .sidebar:hover .brand__text,
  .sidebar:hover .nav__text,
  .sidebar:hover .nav__badge,
  .sidebar:hover .sidebar__label,
  .sidebar:hover .nav__section-title {
    display: inline;
  }

  /* En wide los items dejan de ser círculos */
  .sidebar:hover .nav__item {
    width: auto;
    height: auto;
    padding: 10px 10px;
    margin: 0;
    border-radius: 999px;
    justify-content: flex-start;
  }
}

@media (max-width: 860px) {
  .search {
    width: 220px;
  }

  body.public .auth2 {
    grid-template-columns: 1fr;
  }

  body.public .auth2__side {
    display: none;
  }

  body.public .auth2__main {
    padding: 28px;
  }
}

@media (max-width: 900px) {
  .topbar .userpill__name {
    display: none;
  }

  .topbar .userpill {
    padding: 0 10px;
  }

  .topbar .userpill__chev {
    display: none;
  }
}

@media (max-width: 640px) {
  .search {
    width: 200px;
  }

  .topbar .userpill {
    padding: 0 8px;
  }
}

/* =========================================================
   MOBILE SIDEBAR (off-canvas) - SIN ANIMACIÓN
   Nota: aquí SI hay "aparece / desaparece", pero sin transición.
   ========================================================= */

/* Botón hamburguesa */
.sidebarToggle {
  display: none;
  /* desktop oculto */
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, .10);
  background: #fff;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  flex: 0 0 36px;
}

.sidebarToggle svg {
  width: 18px;
  height: 18px;
  display: block;
  color: rgba(15, 23, 42, .75);
}

.sidebarToggle:hover {
  background: #f9fafb;
}

.sidebarToggle:focus {
  outline: none;
  border-color: rgba(15, 90, 79, 0.35);
  box-shadow: 0 0 0 4px rgba(15, 90, 79, 0.10);
}

/* Overlay */
.sidebarOverlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 8, 23, .45);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  z-index: 19;
  transition: none !important;
}

.sidebarOverlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

html.no-scroll,
body.no-scroll {
  overflow: hidden;
}

/* MOBILE */
@media (max-width: 860px) {
  .sidebarToggle {
    display: inline-flex;
  }

  /* Sidebar off-canvas (sin transición) */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    width: 276px;
    max-width: 86vw;

    transform: translateX(-110%);
    transition: none !important;
    z-index: 30;
    overflow: auto;
  }

  /* No hover en mobile */
  .sidebar:hover {
    width: 276px !important;
    transform: translateX(-110%) !important;
  }

  .sidebar.is-open {
    transform: translateX(0) !important;
  }

  .sidebar.is-open:hover {
    transform: translateX(0) !important;
  }

  /* En mobile: main ocupa todo */
  .main {
    min-width: 0;
  }
}

@media (max-width: 520px) {
  .search {
    display: none;
  }
}