/**
 * TeamDashboard Mobile - Layout & Topbar Styles
 * Estilos del topbar, contenedor principal y layout general
 * Parte 4 de 14
 */

/* ============================================
   SECCIÓN 1: TOPBAR CONTAINER
   ============================================ */

.slv-m-topbar {
    /* Positioning */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: var(--z-sticky);
    
    /* Dimensiones */
    height: var(--topbar-height);
    
    /* Layout interno */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    
    /* Espaciado */
    padding: 0 var(--space-lg);
    padding-top: env(safe-area-inset-top, 0);
    
    /* Background y efectos */
    background: rgba(18, 18, 18, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    
    /* Transiciones */
    transform: translateY(0);
    opacity: 1;
    transition: transform var(--duration-base) var(--ease-out),
                opacity var(--duration-base) var(--ease-out);
    
    /* Optimización */
    will-change: transform;
}

/* Estado oculto del topbar */
.slv-m-topbar[data-visible="false"] {
    transform: translateY(-100%);
    opacity: 0.8;
}

/* Estado de transición */
.slv-m-topbar.is-transitioning {
    pointer-events: none;
}


/* ============================================
   SECCIÓN 2: COLUMNAS DEL TOPBAR
   ============================================ */

/* Columna Izquierda: Logo/Home */
.slv-m-topbar__left {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Columna Centro: Título */
.slv-m-topbar__center {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    padding: 0 var(--space-xs);
}

/* Columna Derecha: Acciones */
.slv-m-topbar__right {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    justify-content: flex-end;
}


/* ============================================
   SECCIÓN 3: ELEMENTOS DEL TOPBAR
   ============================================ */

/* Botón Home/Logo */
.slv-m-topbar__home {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    
    /* Reset de botón */
    background: transparent;
    border: none;
    padding: var(--space-xs);
    margin: 0;
    
    /* Estilo de texto */
    color: var(--color-text-primary);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    font-family: var(--font-primary);
    text-decoration: none;
    
    /* Interacción */
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    
    /* Transición */
    opacity: 1;
    transition: opacity var(--duration-fast) var(--ease-out);
    
    /* Touch target */
    min-height: 40px;
    border-radius: var(--radius-sm);
}

.slv-m-topbar__home:hover,
.slv-m-topbar__home:focus {
    opacity: 0.7;
}

.slv-m-topbar__home:active {
    opacity: 0.5;
    transform: scale(0.98);
}

.slv-m-topbar__home:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Icono del home */
.slv-m-topbar__home-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    color: var(--color-primary);
}

/* Texto del home */
.slv-m-topbar__home-text {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    white-space: nowrap;
    letter-spacing: 0.5px;
}

/* Responsive: Ocultar texto en pantallas muy pequeñas */
@media (max-width: 360px) {
    .slv-m-topbar__home-text {
        display: none;
    }
}


/* ============================================
   SECCIÓN 4: TÍTULO CONTEXTUAL
   ============================================ */

.slv-m-topbar__title {
    /* Reset de heading */
    margin: 0;
    padding: 0;
    
    /* Estilo de texto */
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--color-text-primary);
    line-height: 1.2;
    
    /* Truncado si es muy largo */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    
    /* Transición suave al cambiar */
    transition: opacity var(--duration-fast) var(--ease-out);
}

/* Animación al cambiar título */
.slv-m-topbar__title.is-changing {
    opacity: 0;
}


/* ============================================
   SECCIÓN 5: BOTONES DE ACCIÓN
   ============================================ */

.slv-m-topbar__action {
    /* Positioning para badge */
    position: relative;
    
    /* Dimensiones */
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    
    /* Reset de botón */
    background: transparent;
    border: none;
    padding: 0;
    margin: 0;
    
    /* Layout */
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Estilo */
    color: var(--color-text-secondary);
    border-radius: var(--radius-sm);
    
    /* Interacción */
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    
    /* Transición */
    transition: background-color var(--duration-fast) var(--ease-out),
                color var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
}

.slv-m-topbar__action:hover,
.slv-m-topbar__action:focus {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary);
}

.slv-m-topbar__action:active {
    transform: scale(0.95);
    background-color: rgba(255, 255, 255, 0.15);
}

.slv-m-topbar__action:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Iconos de acción */
.slv-m-topbar__action-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}


/* ============================================
   SECCIÓN 6: BADGE DE NOTIFICACIONES
   ============================================ */

.slv-m-badge {
    /* Positioning */
    position: absolute;
    top: 4px;
    right: 4px;
    
    /* Dimensiones */
    min-width: 18px;
    height: 18px;
    
    /* Layout */
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Espaciado */
    padding: 0 5px;
    
    /* Estilo */
    background-color: var(--color-error);
    color: var(--color-text-on-primary);
    border-radius: var(--radius-full);
    border: 2px solid var(--color-bg-primary);
    
    /* Texto */
    font-size: 10px;
    font-weight: var(--font-bold);
    line-height: 1;
    white-space: nowrap;
    
    /* Animación de entrada */
    animation: badgeBounce 0.4s var(--ease-bounce);
}

/* Badge oculto cuando count es 0 */
.slv-m-badge[data-count="0"],
.slv-m-badge:empty {
    display: none;
}

/* Animación de bounce para badge */
@keyframes badgeBounce {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}


/* ============================================
   SECCIÓN 7: LAYOUT PRINCIPAL
   ============================================ */

/* Wrapper principal del dashboard */
.teamdashboard-mobile-wrapper {
    /* Positioning y dimensiones */
    position: relative;
    min-height: 100vh;
    width: 100%;
    
    /* Espaciado para topbar y bottom-nav */
    padding-top: var(--topbar-height);
    padding-bottom: var(--bottom-nav-height);
    
    /* Background */
    background: var(--color-bg-primary);
    
    /* Overflow */
    overflow-x: hidden;
}

/* Contenedor de contenido principal */
.slv-m-content {
    /* Dimensiones */
    min-height: calc(100vh - var(--topbar-height) - var(--bottom-nav-height));
    width: 100%;
    max-width: 100%;
    
    /* Espaciado */
    padding: var(--space-md);
    padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom, 0));
    
    /* Background */
    background: var(--color-bg-primary);
    
    /* Overflow */
    overflow-y: auto;
    overflow-x: hidden;
    
    /* Scroll suave */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}


/* ============================================
   SECCIÓN 8: SISTEMA DE VISTAS
   ============================================ */

/* Vista individual */
.slv-m-view {
    /* Display */
    display: none;
    
    /* Dimensiones */
    width: 100%;
    min-height: 100%;
    
    /* Transición */
    opacity: 0;
    transform: translateY(10px);
    transition: opacity var(--duration-base) var(--ease-out),
                transform var(--duration-base) var(--ease-out);
}

/* Vista activa */
.slv-m-view.is-active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Vista en transición de salida */
.slv-m-view.is-exiting {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

/* Vista en transición de entrada */
.slv-m-view.is-entering {
    opacity: 0;
    transform: translateY(10px);
}


/* ============================================
   SECCIÓN 9: ESTADOS ESPECIALES DEL TOPBAR
   ============================================ */

/* Topbar cuando el scroll está en el top */
.slv-m-topbar.is-at-top {
    box-shadow: none;
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

/* Topbar con background sólido (sin blur) */
.slv-m-topbar.is-solid {
    background: var(--color-bg-elevated);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* Topbar en modo compacto (opcional para futuro) */
.slv-m-topbar.is-compact {
    height: calc(var(--topbar-height) * 0.8);
}


/* ============================================
   SECCIÓN 10: RESPONSIVE Y MEDIA QUERIES
   ============================================ */

/* Tablets pequeñas */
@media (min-width: 480px) {
    .slv-m-content {
        padding: var(--space-lg);
    }
}

/* Tablets */
@media (min-width: 768px) {
    /* Aumentar padding del topbar */
    .slv-m-topbar {
        padding: 0 var(--space-xl);
    }
    
    /* Aumentar tamaño de título */
    .slv-m-topbar__title {
        font-size: var(--text-lg);
    }
    
    /* Mostrar siempre el texto del home */
    .slv-m-topbar__home-text {
        display: inline;
    }
    
    /* Aumentar padding del contenido */
    .slv-m-content {
        padding: var(--space-xl);
        max-width: 768px;
        margin: 0 auto;
    }
}


/* ============================================
   SECCIÓN 11: DARK MODE (OPCIONAL)
   ============================================ */

@media (prefers-color-scheme: light) {
    .slv-m-topbar {
        background: rgba(255, 255, 255, 0.9);
        border-bottom-color: rgba(0, 0, 0, 0.1);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    .slv-m-topbar__action:hover,
    .slv-m-topbar__action:focus {
        background-color: rgba(0, 0, 0, 0.05);
    }
    
    .slv-m-topbar__action:active {
        background-color: rgba(0, 0, 0, 0.1);
    }
}


/* ============================================
   SECCIÓN 12: ACCESSIBILITY
   ============================================ */

/* Reducir movimiento para usuarios con preferencias de accesibilidad */
@media (prefers-reduced-motion: reduce) {
    .slv-m-topbar,
    .slv-m-topbar__title,
    .slv-m-topbar__action,
    .slv-m-topbar__home,
    .slv-m-view {
        transition: none;
        animation: none;
    }
    
    .slv-m-badge {
        animation: none;
    }
}

/* Focus visible para navegación por teclado */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}


/* ============================================
   SECCIÓN 13: PRINT STYLES
   ============================================ */

@media print {
    .slv-m-topbar,
    .slv-m-bottom-nav {
        display: none;
    }
    
    .teamdashboard-mobile-wrapper {
        padding-top: 0;
        padding-bottom: 0;
    }
    
    .slv-m-content {
        min-height: auto;
    }
}


/* ============================================
   SECCIÓN 14: LOADING STATES
   ============================================ */

/* Skeleton loader para título */
.slv-m-topbar__title.is-loading {
    width: 120px;
    height: 20px;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.1) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
    color: transparent;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}