/* ==========================================================================
   Layout Shell: App Bar Superior y Sidebar Navegación (Material 3 Expressive)
   ========================================================================== */

/* Contenedor principal de la aplicación */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  overflow: hidden;
  background-color: var(--md-sys-color-background, #fdf8fd);
  box-sizing: border-box;
}

/* Barra superior (App Bar) */
.app-top-bar {
  flex: none;
  border-bottom: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
  background-color: var(--md-sys-color-surface, #ffffff);
  z-index: 10;
}

.sidebar-toggle-btn {
  --m3e-button-min-size: 44px;
}

/* Sección de marca / logo en App Bar */
.app-bar-brand-section {
  display: flex;
  align-items: center;
  min-width: 0;
  margin-inline-start: 0.25rem;
}

.app-bar-brand-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.app-bar-logo {
  height: 32px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
  display: block;
}

.logo-dark {
  display: none;
}

.logo-light {
  display: block;
}

:root.dark .logo-dark,
html.dark .logo-dark {
  display: block;
}

:root.dark .logo-light,
html.dark .logo-light {
  display: none;
}

.app-bar-user-section {
  display: flex;
  align-items: center;
  min-width: 0;
}

.app-bar-user-profile {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.app-bar-user-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
  text-align: right;
  min-width: 0;
  line-height: 1.2;
}

.app-bar-badges {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.app-bar-user-title {
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  color: var(--md-sys-color-on-surface, #1d1b20);
  white-space: nowrap;
}

.app-bar-user-subtitle {
  font-size: 0.8125rem;
  color: var(--md-sys-color-on-surface-variant, #49454f);
  margin-top: 1px;
  line-height: 1.2;
  white-space: nowrap;
}

/* ==========================================================================
   Componente Reutilizable: Avatar de Colaborador e Indicadores de Estado
   ========================================================================== */
.colaborador-avatar-component {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.colaborador-avatar-component .avatar-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--md-sys-color-primary, #6750a4), var(--md-sys-color-tertiary, #7d5260));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9375rem;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
  overflow: hidden;
  user-select: none;
}

.colaborador-avatar-component .colaborador-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

.colaborador-avatar-component .avatar-initials {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Modificadores de Tamaño */
.colaborador-avatar-component--sm .avatar-circle {
  width: 38px;
  height: 38px;
  font-size: 0.8125rem;
}

.colaborador-avatar-component--md .avatar-circle {
  width: 44px;
  height: 44px;
  font-size: 0.9375rem;
}

.colaborador-avatar-component--lg .avatar-circle {
  width: 120px;
  height: 120px;
  font-size: 2.75rem;
  border: 4px solid var(--md-sys-color-surface, #ffffff);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Indicador de Estado Circular Superpuesto (Superior Derecha) */
.avatar-status-dot {
  position: absolute;
  top: 0;
  right: 0;
  border-radius: 50%;
  border: 2px solid var(--md-sys-color-surface, #ffffff);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  z-index: 2;
  box-sizing: border-box;
}

.colaborador-avatar-component--sm .avatar-status-dot {
  width: 11px;
  height: 11px;
  border-width: 2px;
  transform: translate(15%, -15%);
}

.colaborador-avatar-component--md .avatar-status-dot {
  width: 13px;
  height: 13px;
  border-width: 2px;
  transform: translate(15%, -15%);
}

.colaborador-avatar-component--lg .avatar-status-dot {
  width: 26px;
  height: 26px;
  border-width: 4px;
  transform: translate(12%, -12%);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Variantes de Color del Estado del Usuario */
.avatar-status-dot--active,
.avatar-status-dot--turno {
  background-color: #22c55e;
}

.avatar-status-dot--comida {
  background-color: #eab308;
}

.avatar-status-dot--fuera,
.avatar-status-dot--inactive,
.avatar-status-dot--inactivo {
  background-color: #9ca3af;
}

/* Permisos: Vacaciones -> Morado */
.avatar-status-dot--vacaciones {
  background-color: #9333ea;
}

/* Permisos: Home office -> Azul */
.avatar-status-dot--home_office,
.avatar-status-dot--home-office {
  background-color: #2563eb;
}

/* Permisos: Incapacidad -> Rosa */
.avatar-status-dot--incapacidad {
  background-color: #ec4899;
}

/* Permisos: Ausencia de labores -> Naranja */
.avatar-status-dot--ausencia {
  background-color: #ea580c;
}

/* ==========================================================================
   Badges / Chips (Estilo ver detalles de usuario)
   ========================================================================== */
.detail-badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.detail-badge-chip.puesto {
  background-color: var(--md-sys-color-surface-container-highest, #e6e0e9);
  color: var(--md-sys-color-on-surface, #1d1b20);
}

.detail-badge-chip.departamento {
  background-color: var(--md-sys-color-secondary-container, #e8def8);
  color: var(--md-sys-color-on-secondary-container, #1d192b);
}

.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  background-color: var(--md-sys-color-tertiary-container, #ffd8e4);
  color: var(--md-sys-color-on-tertiary-container, #31111d);
  white-space: nowrap;
}

.detail-badge-chip m3e-icon,
.role-chip m3e-icon {
  font-size: 16px;
  --m3e-icon-size: 16px;
}

.app-bar-badges .detail-badge-chip,
.app-bar-badges .role-chip {
  padding: 0.2rem 0.65rem;
  font-size: 0.75rem;
}

.app-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-inline-end: 0.5rem;
}

.app-bar-link {
  text-decoration: none;
  display: inline-flex;
}

/* Transiciones suaves al alternar tema (activadas tras la carga inicial) */
body.theme-transitions,
body.theme-transitions .app-shell,
body.theme-transitions .app-top-bar,
body.theme-transitions .app-sidebar,
body.theme-transitions .app-main-viewport,
body.theme-transitions .detail-badge-chip,
body.theme-transitions .role-chip {
  transition: background-color 0.25s cubic-bezier(0.2, 0, 0, 1),
              color 0.25s cubic-bezier(0.2, 0, 0, 1),
              border-color 0.25s cubic-bezier(0.2, 0, 0, 1);
}

/* Contenedor Drawer para Sidebar y Contenido */
#main-drawer-container {
  flex: 1 1 auto;
  height: calc(100vh - 64px);
  overflow: hidden;
  --m3e-drawer-container-width: 280px;
}

/* Barra lateral (Sidebar) */
.app-sidebar {
  width: 280px;
  height: 100%;
  box-sizing: border-box;
  padding: 1rem 0.75rem;
  background-color: var(--md-sys-color-surface-container-low, #f7f2fa);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.sidebar-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.sidebar-nav-menu {
  width: 100%;
}

.sidebar-footer {
  flex: none;
  padding-top: 0.75rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--md-sys-color-outline-variant, #cac4d0);
}

.sidebar-logout-link {
  text-decoration: none;
  display: block;
  width: 100%;
}

.sidebar-logout-btn {
  width: 100%;
  justify-content: center;
  --m3e-button-width: 100%;
  display: flex;
}

.sidebar-group-heading {
  padding: 0.5rem 1rem;
  color: var(--md-sys-color-primary, #6750a4);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Área de contenido principal desplazable */
.app-main-viewport {
  min-height: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  padding: 1.5rem 2rem;
  background-color: var(--md-sys-color-background, #fdf8fd);
}

/* Adaptabilidad para dispositivos móviles y tabletas */
@media (max-width: 768px) {
  .app-main-viewport {
    padding: 1rem;
  }

  .app-bar-user-subtitle {
    display: none;
  }

  .app-bar-badges .detail-badge-chip,
  .app-bar-badges .role-chip {
    padding: 0.15rem 0.5rem;
    font-size: 0.6875rem;
  }
}

@media (max-width: 576px) {
  .app-bar-badges {
    display: none;
  }
}
