/**
 * ESTILOS DE MÓDULO: m_menu_dash
 * Identidad: estilos_m_menu_dash.css
 * Descripción: Sistema de navegación homologado, Rigor Institucional, Mobile-First.
 */

@import url('../nucleo/estilos_tokens.css');

:root {
  --dash-bg-dark: var(--color-fondo-base);
  --dash-surface-glass: var(--color-superficie);
  --dash-border-glass: var(--color-borde-firme);
  --dash-accent-blue: var(--color-primario-cobalto);
  --dash-accent-cyan: var(--color-primario-hover);
  --dash-text-bright: var(--color-texto-titular);
  --dash-text-muted: var(--color-texto-atenuado);
  --dash-font-heading: var(--fuente-titulos);
  --dash-font-body: var(--fuente-cuerpo);
}

/* Wrapper general */
.m-menu-dash-wrapper {
  font-family: var(--dash-font-body);
}

/* Soporte de Layout Universal para vistas que integran m_menu_dash */
body.dash-body {
  margin: 0;
  padding: 0;
  background-color: var(--color-fondo-base);
  color: var(--color-texto-cuerpo);
  font-family: var(--dash-font-body);
  min-height: 100vh;
}

.dash-main-content {
  padding-top: 1.5rem;
  padding-bottom: 80px;
  min-height: 100vh;
  box-sizing: border-box;
  transition: margin 0.2s ease, width 0.2s ease;
}

@media (min-width: 768px) {
  .dash-main-content {
    margin-left: 260px;
    width: calc(100% - 260px);
    max-width: calc(100% - 260px);
    padding-left: 2rem;
    padding-right: 2rem;
    padding-bottom: 2.5rem;
  }
}

@media (max-width: 767px) {
  .dash-main-content {
    margin-left: 0;
    width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
    padding-bottom: 90px;
  }
}


/* -------------------------------------------------------------
   ESCRITORIO (>= 768px): MENÚ LATERAL SIDEBAR
   ------------------------------------------------------------- */
@media (min-width: 768px) {
  .m-menu-dash-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    background: var(--dash-surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--dash-border-glass);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    padding: 1.5rem 1rem;
    box-sizing: border-box;
  }

  .m-menu-dash-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--dash-border-glass);
    margin-bottom: 1.5rem;
  }

  .m-menu-dash-logo {
    height: 32px;
    width: 32px;
    border-radius: 8px;
    object-fit: contain;
  }

  .m-menu-dash-title {
    font-family: var(--dash-font-heading);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--dash-text-bright);
    letter-spacing: -0.02em;
  }

  .m-menu-dash-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
  }

  .m-menu-dash-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    color: var(--dash-text-muted);
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    border: 1px solid transparent;
  }

  .m-menu-dash-item:hover {
    color: var(--dash-text-bright);
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.05);
  }

  .m-menu-dash-item.activo {
    color: var(--dash-text-bright);
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(6, 182, 212, 0.15));
    border-color: rgba(59, 130, 246, 0.3);
    font-weight: 600;
  }

  .m-menu-dash-item svg {
    stroke: currentColor;
    transition: stroke 0.2s ease;
  }

  .m-menu-dash-footer {
    position: relative;
    padding-top: 1rem;
    border-top: 1px solid var(--dash-border-glass);
  }

  /* Tarjeta del Usuario en el Pie del Sidebar */
  .m-menu-dash-user-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: var(--color-superficie-elevada);
    border: 1px solid var(--color-borde-firme);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
  }

  .m-menu-dash-user-card:hover {
    background: var(--color-superficie-hover);
    border-color: var(--color-borde-enfocado);
  }

  .user-card-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--dash-accent-blue), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
  }

  .user-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    overflow: hidden;
    flex: 1;
  }

  .user-card-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--dash-text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .user-card-role {
    font-size: 0.72rem;
    color: var(--dash-text-muted);
  }

  .user-card-arrow {
    color: var(--dash-text-muted);
    transition: transform 0.25s ease;
  }

  /* POPOVER FLOTANTE ASCENDENTE */
  .m-menu-dash-popover {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 0;
    right: 0;
    background: var(--color-superficie);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--color-borde-firme);
    border-radius: 16px;
    box-shadow: var(--sombra-elevada);
    padding: 1rem;
    box-sizing: border-box;
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .m-menu-dash-popover.activo {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .popover-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.85rem;
    border-bottom: 1px solid var(--color-borde-sutil);
    margin-bottom: 0.75rem;
  }

  .popover-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--dash-accent-blue), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.95rem;
  }

  .popover-details {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    overflow: hidden;
  }

  .popover-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-texto-titular);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .popover-email {
    font-size: 0.75rem;
    color: var(--dash-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .popover-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
  }

  .popover-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    color: var(--dash-text-bright);
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 500;
    transition: all 0.2s ease;
  }

  .popover-link:hover {
    background: var(--color-superficie-hover);
  }

  .popover-link.logout {
    color: #fca5a5;
  }

  .popover-link.logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
  }

  .m-menu-dash-bottom-nav,
  .m-menu-dash-sheet-overlay,
  .m-menu-dash-sheet {
    display: none;
  }
}

/* -------------------------------------------------------------
   MÓVIL (< 768px): BARRA INFERIOR Y MOBILE BOTTOM SHEET
   ------------------------------------------------------------- */
@media (max-width: 767px) {
  .m-menu-dash-sidebar {
    display: none;
  }

  .m-menu-dash-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--color-superficie);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--color-borde-firme);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding: 0 0.5rem;
    box-sizing: border-box;
  }

  .m-menu-dash-item-movil {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    color: var(--dash-text-muted);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    min-width: 54px;
    height: 48px;
    border-radius: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
  }

  .m-menu-dash-item-movil:hover,
  .m-menu-dash-item-movil.activo {
    color: var(--dash-accent-cyan);
  }

  .m-menu-dash-item-movil svg {
    stroke: currentColor;
    width: 20px;
    height: 20px;
  }

  /* HOJA EMERGENTE MÓVIL (MOBILE BOTTOM SHEET) */
  .m-menu-dash-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .m-menu-dash-sheet-overlay.activo {
    opacity: 1;
    visibility: visible;
  }

  .m-menu-dash-sheet {
    position: fixed;
    bottom: -350px;
    left: 0;
    right: 0;
    background-color: var(--color-superficie);
    border-top: 1px solid var(--color-borde-firme);
    border-radius: 20px 20px 0 0;
    z-index: 1201;
    padding: 1.5rem;
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--sombra-elevada);
  }

  .m-menu-dash-sheet.activo {
    bottom: 0;
  }

  .sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--color-borde-firme);
    border-radius: 2px;
    margin: 0 auto 0.5rem auto;
  }

  .sheet-user-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-borde-sutil);
  }

  .sheet-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--dash-accent-blue), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 700;
    font-size: 1.1rem;
  }

  .sheet-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-texto-titular);
  }

  .sheet-email {
    font-size: 0.8rem;
    color: var(--dash-text-muted);
  }

  .sheet-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .sheet-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: var(--color-superficie-elevada);
    border: 1px solid var(--color-borde-sutil);
    color: var(--dash-text-bright);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    transition: all 0.2s ease;
  }

  .sheet-link:hover,
  .sheet-link:active {
    background: var(--color-superficie-hover);
    color: var(--dash-text-bright);
  }

  .sheet-btn-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    font-weight: 600;
    font-size: 0.88rem;
    padding: 0.65rem 1.25rem;
    border-radius: 12px;
    cursor: pointer;
    width: fit-content;
    margin: 0.5rem auto 0 auto;
    transition: all 0.2s ease;
  }
}
