/******* 🌐 Global Variables *******/
:root {
  --env-banner-height: 15px;
}

body {
    overflow-x: hidden;
    overscroll-behavior: none;
}
/* Bloquea scroll del body cuando el sidebar menu está abierto */
body.sidebar-open {
    overflow: hidden;
    touch-action: none;
}

/******* 🌐 Banner de entorno *******/
.env-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--env-banner-height);
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    line-height: 5px;
    z-index: 3000;
    padding: 4px;
    color: #fff;
}
.env-dev {
  background: rgba(220, 53, 69, 0.7);
  backdrop-filter: blur(6px);
}
.env-test {
  background: rgba(255, 193, 7, 0.7);
  color: #000;
  backdrop-filter: blur(6px);
}
/* Ajusta el contenido para no quedar oculto tras el banner */
body.has-env-banner {
  padding-top: var(--env-banner-height); /* misma altura del banner */
}
#appContent {
  transition: margin-top 0.2s ease; /* transición suave */
}
body.has-env-banner .sidebar {
  top: var(--env-banner-height); /* misma altura del banner */
  height: calc(100vh - var(--env-banner-height));
}
body.has-env-banner .navbar {
  top: var(--env-banner-height); /* misma altura del banner */
}

/******* 🔄 Loader *******/
.app-loader {
  position: fixed;
  inset: 0;
  background: #212529;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 1;
  transition: opacity 0.4s ease;
}
.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.loader-text {
  margin-top: 10px;
  font-size: 0.95rem;
  color: #6c757d;
}

/* 🚀 App */
.app-hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.app-visible {
  opacity: 1;
  pointer-events: auto;
}

/******* Sidebar *******/
.sidebar {
    width: 280px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    background-color: #212529;
    padding-top: 1rem;
    z-index: 1050;          /* 🔑 CLAVE PARA TRAERLO ARRIBA DEL CONTENIDO */
    display: flex;          /* 👈 CLAVE PARA EL USER PROFILE */
    flex-direction: column; /* 👈 CLAVE PARA EL USER PROFILE */
    overflow: hidden;       /* 🔑 CLAVE PARA DEJAR SCROLL AL MENU SOLAMENTE */
    transition: top 0.2s ease, height 0.2s ease;
}
.nav-link {
  cursor: pointer;          /* Para evitar bugs en iPhone */
}
/* Cuando el menu está activo, anulamos la clase: link-body-emphasis */
.nav-link.active {
  color: var(--bs-nav-pills-link-active-color) !important;
  background-color: var(--bs-nav-pills-link-active-bg);
}
.nav-link.link-body-emphasis:not(.active) {
  color: var(--bs-body-color);
}
.sidebar-logo-img {
  max-width: 180px;
  width: 100%;
  height: auto;
}
.sidebar-menu {
  flex-grow: 1;
  /* Menú scrolleable */
  overflow-y: auto;
  min-height: 0;                     /* 🔑 CLAVE para que flex funcione bien con overflow */
  -webkit-overflow-scrolling: touch; /* iOS smooth scroll */
}
.sidebar-menu a:hover {
    background-color: #d8e0f4;
    color: #fff;
}
.sidebar a {
    color: #adb5bd;
    text-decoration: none;
    padding: 10px 20px;
    display: block;
    font-size: 0.95rem;
    transition: background-color 0.2s ease, color 0.2s ease;
}
.sidebar a.active {
    background-color: #495057;
    color: #fff;
}
.sidebar-open::before {
    content: "";
    position: fixed;
    top: calc(56px + var(--env-banner-height));
    left: 0;
    width: 100vw;
    height: calc(100vh - 56px - var(--env-banner-height));
    background: linear-gradient(
        rgba(0,0,0,0.45),
        rgba(0,0,0,0.55)
    );
    z-index: 1040;
}
.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(118, 118, 118, 0.5); /* Color título sección sidebar menu */
  margin: 16px 20px 8px;
  pointer-events: none;
  user-select: none;
}

/* Sidebar user */
.sidebar-divider {
    margin: 8px 0;
    border-color: #343a40;
}
.sidebar-user {
    /* Perfil siempre visible */
    flex-shrink: 0;     /* 🔑 */
    position: sticky;
    bottom: env(safe-area-inset-bottom);
    background-color: #212529;
    border-top: 1px solid rgba(0,0,0,.1);
    padding: 0.75rem 1rem;
}
.sidebar-user a {
    padding: 0;
}
.sidebar-user .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-user .dropdown-toggle::after {
    margin-left: auto;
}
.sidebar-user-toggle {
    justify-content: space-between;
}
.sidebar-user-toggle::after {
    margin-left: auto;
}
/* Transición suave para dropdown del sidebar user */
.sidebar-user .dropdown-menu {
    opacity: 0;
    transform: translateY(10px);
    transition:
        opacity 0.25s cubic-bezier(.4,0,.2,1),
        transform 0.25s cubic-bezier(.4,0,.2,1);
    display: block;         /* 🔑 importante */
    pointer-events: none;   /* evita clicks cuando está cerrado */
}
.sidebar-user .dropdown-menu.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;        /* evita deformación en flex */
    border-radius: 50%;
    background-color: #495057;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 1;         /* 🔑 CLAVE para texto centrado */
    overflow: hidden;       /* seguridad */
}
.user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #000;
}
.user-role {
    font-size: 0.75rem;
    color: #adb5bd;
}

/* Sidebar móvil */
@media (max-width: 991.98px) {
    .sidebar {
        left: -280px;
        transition: left 0.3s ease;
    }
    .sidebar-open .sidebar {
        left: 0;
    }
    .sidebar-menu{
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }
    .content {
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    }
    /* 📱 Móvil: shadow SOLO cuando el sidebar está abierto */
    body.sidebar-open .sidebar {
        box-shadow: 6px 0 20px rgba(0, 0, 0, 0.45);
    }
}
@media (min-width: 992px) {
    .content {
        margin-left: 280px;
    }
}
/* Evita que se “coma” el perfil en pantallas muy bajas */
@media (max-height: 700px) {
    .sidebar-menu {
        padding-bottom: 1rem;
    }
}

/******* Contenido *******/
.content {
    margin-top: 56px;
    padding: 20px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    transition: margin-left 0.3s ease;
    -webkit-overflow-scrolling: touch; /* iOS smooth scroll */
}
/* Desktop: NO navbar */
@media (min-width: 992px) {
    .content {
        padding-left: 50px;
        margin-top: 0;
        height: 100vh;
    }
    .sidebar {
        background: #0b1220;
        /* Shadow fijo en desktop */
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.2);
    }
}
/* Overlay oscuro del sidebar solo exista en móvil */
@media (min-width: 992px) {
    .sidebar-open::before {
        display: none;
    }
}

/* Room Cards */
.room-card {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.room-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.15);
}
.room-free {
    background-color: #ffffff; /*#e6f4ea;*/
    border-left: 6px solid #198754;
}
.room-occupied {
    background-color: #fdecea;
    border-left: 6px solid #dc3545;
}
.room-number {
    font-size: 1.5rem;
    font-weight: 600;
}