/*
 * App shell de SpookFact: layout compartido del panel (admin y tenant).
 * Patron: el body no scrollea; el sidebar es fijo full-height, el topbar
 * queda arriba y SOLO el contenido principal scrollea.
 */

.panel-body {
  min-height: 100vh;
}

/* ---------- Scroll global del panel ---------- */

/* Una sola barra, delgada y con los colores del tema (WebKit y Firefox):
 * la barra nativa de Windows es ancha y no combina con el diseno. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
  border: 2px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-corner {
  background: transparent;
}

.tenant-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Sidebar ---------- */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--sidebar-shell);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: margin-left 0.2s ease;
  /* Sin scroll propio: el unico scroll del sidebar es el de la nav (evita
   * dos barras anidadas cuando hay muchos items). */
  overflow: hidden;
  box-shadow: var(--sidebar-shadow);
}

.sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--sidebar-header-bg);
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sidebar-brand-text strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--text);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 1rem 0.75rem;
  flex: 1;
  overflow-y: auto;
  justify-content: flex-start;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--sidebar-item-text);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  transition:
    background 0.15s ease,
    color 0.15s ease;
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-3);
  transition: color 0.15s ease;
}

.sidebar-link:hover {
  background: var(--sidebar-item-hover);
  color: var(--text);
}

.sidebar-link:hover svg {
  color: var(--accent);
}

.sidebar-link.active {
  background: var(--sidebar-item-active);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-link.active svg {
  color: var(--accent);
}

.sidebar-footer {
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: var(--sidebar-footer-bg);
}

/* ---------- Main ---------- */

.tenant-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.tenant-layout .topbar {
  flex-shrink: 0;
}

.tenant-layout .panel-main {
  flex: 1;
  overflow-y: auto;
  max-width: none;
  margin: 0;
  padding: 1.25rem 1.5rem 2.5rem;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.topbar-brand .auth-logo-mark {
  width: 32px;
  height: 32px;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-email {
  color: var(--text-2);
  font-size: 0.85rem;
}

.sidebar-toggle {
  font-size: 1.1rem;
  padding: 0.2rem 0.6rem;
}

/* ---------- Transicion de vistas ---------- */

.tenant-section {
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    z-index: 10;
    margin-left: calc(-1 * var(--sidebar-width));
  }

  .sidebar:not(.collapsed) {
    margin-left: 0;
    box-shadow: 0 0 0 100vmax var(--modal-overlay);
  }

  .sidebar-toggle {
    display: inline-block;
  }

  .topbar-email {
    display: none;
  }
}
