/* =========================================================
  Loliando - mobile-navigation.css 
  Navegación móvil reutilizable para todas las páginas
  ========================================================= */

/* ===== BARRA INFERIOR MÓVIL MEJORADA ===== */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: none;
    z-index: 1000;
    /* Aumentamos el padding inferior para separar los botones de la barra de sistema */
    padding: 12px 12px max(20px, env(safe-area-inset-bottom, 20px));
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.12);
    min-height: 80px;
    /* Aumentamos altura mínima */
    box-sizing: border-box;
    overflow: hidden;
}

.mobile-nav-btn {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #666;
    padding: 8px 6px;
    position: relative;
    transition: color 0.3s ease, transform 0.1s ease;
    min-height: 56px;
    justify-content: center;
}

.mobile-nav-btn.active {
    color: #00a650;
}

.nav-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 2px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-icon svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    transition: fill 0.3s ease;
}

.nav-label {
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    margin-top: 2px;
    display: block;
    line-height: 1.2;
    color: inherit;
}

.nav-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid white;
}

.nav-badge.visible {
    display: flex;
}

.notificacion-icono-mobile,
.carrito-icono-mobile {
    position: relative;
}

.user-avatar-mobile {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #3483fa;
    border: 2px solid transparent;
    transition: border-color 0.3s;
    margin-bottom: 2px;
}

.avatar-img-mobile {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-avatar-mobile:not([has-img]) {
    background-color: #3483fa;
    color: white;
    font-weight: bold;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mensajes-btn {
    position: relative !important;
}

.mensaje-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 2px solid white;
}

.mensaje-badge.visible {
    display: flex;
}

.contador-notificaciones-mobile,
.contador-carrito-mobile {
    background-color: #ff4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    display: none;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: -6px;
    right: -8px;
    font-weight: bold;
    border: 3px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.contador-notificaciones-mobile.visible,
.contador-carrito-mobile.visible {
    display: flex;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
    }

    html,
    body {
        overflow-x: hidden;
    }

    body {
        /* Ajustamos el padding del body para compensar la nueva altura del nav */
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 20px)) !important;
    }

    main,
    .main-content,
    #productos,
    .pagina-notificaciones {
        margin-bottom: calc(80px + env(safe-area-inset-bottom, 20px)) !important;
    }
}

@media (max-width: 480px) {
    .mobile-bottom-nav {
        min-height: 75px;
        padding: 10px 8px max(18px, env(safe-area-inset-bottom, 18px));
    }

    .mobile-nav-btn {
        min-height: 52px;
        padding: 6px 4px;
    }

    .nav-icon {
        width: 26px;
        height: 26px;
    }

    .nav-icon svg {
        width: 26px;
        height: 26px;
    }

    .nav-label {
        font-size: 9px;
    }

    .user-avatar-mobile {
        width: 28px;
        height: 28px;
    }

    .user-avatar-mobile:not([has-img]) {
        font-size: 9px;
    }

    .nav-badge {
        width: 16px;
        height: 16px;
        font-size: 10px;
        top: -5px;
        right: -6px;
    }

    .contador-notificaciones-mobile,
    .contador-carrito-mobile {
        width: 18px;
        height: 18px;
        font-size: 10px;
        top: -5px;
        right: -6px;
        border-width: 2px;
    }

    body {
        padding-bottom: calc(75px + env(safe-area-inset-bottom, 18px)) !important;
    }
}

.mobile-top-controls {
    display: none;
    width: 100%;
}

@media (max-width: 768px) {
    .mobile-top-controls {
        display: flex !important;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        gap: 6px;
        padding: 6px 12px;
        align-items: center;
        justify-content: space-between;
        margin: 4px auto;
    }

    .mobile-top-controls .categorias {
        flex: 0 0 auto;
        min-width: 0;
        max-width: 120px;
        position: relative;
    }

    .mobile-top-controls .categorias .dropdown-btn {
        max-width: 120px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 6px 10px;
        font-size: 12px;
    }

    .mobile-top-controls .categorias .dropdown-content {
        position: absolute;
        left: 0;
        top: calc(100% + 6px);
        z-index: 1100;
        width: max-content;
        min-width: 120px;
        max-width: 320px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
        background: white;
    }

    .mobile-top-controls .center-control {
        flex: 1 1 auto;
        display: flex;
        justify-content: center;
    }

    .mobile-top-controls .right-control {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        justify-content: flex-end;
    }

    .mobile-top-controls .vender-btn {
        padding: 6px 10px;
        font-size: 12px;
        border-radius: 4px;
    }

    .mobile-top-controls .mensajes-btn {
        background: none;
        border: none;
        padding: 3px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #666;
        position: relative;
    }

    .mobile-top-controls .mensajes-btn svg {
        width: 24px;
        height: 24px;
        display: block;
        min-width: 24px;
    }

    .mobile-top-controls .contador-mensajes-mobile {
        min-width: 16px;
        height: 16px;
        font-size: 10px;
        top: -4px;
        right: -4px;
        padding: 0 4px;
    }
}

@media (max-width: 480px) {
    .mobile-top-controls {
        gap: 5px;
        padding: 5px 10px;
        margin: 3px auto;
    }

    .mobile-top-controls .categorias {
        max-width: 100px;
    }

    .mobile-top-controls .categorias .dropdown-btn {
        max-width: 100px;
        padding: 5px 8px;
        font-size: 11px;
    }

    .mobile-top-controls .vender-btn {
        padding: 5px 8px;
        font-size: 11px;
    }

    .mobile-top-controls .mensajes-btn svg {
        width: 22px;
        height: 22px;
        min-width: 22px;
    }

    .mobile-top-controls .contador-mensajes-mobile {
        min-width: 14px;
        height: 14px;
        font-size: 9px;
        top: -3px;
        right: -3px;
        padding: 0 3px;
    }
}

.mobile-nav-btn:hover {
    color: #00a650;
}

.mobile-nav-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

.mobile-nav-btn.user-profile-mobile.active .user-avatar-mobile {
    border-color: #00a650;
}

.mobile-nav-btn.user-profile-mobile.active .user-avatar-mobile:not([has-img]) {
    background-color: #00a650;
}

.mobile-nav-btn.active::after {
    content: '';
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: #00a650;
    border-radius: 50%;
}

.mobile-bottom-nav,
.mobile-nav-btn,
.nav-icon,
.nav-label {
    transition: all 0.3s ease;
}

@supports (padding: max(0px)) {
    .mobile-bottom-nav {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

@supports (-webkit-touch-callout: none) {
    .mobile-bottom-nav {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    body {
        padding-bottom: calc(85px + max(20px, env(safe-area-inset-bottom))) !important;
    }
}

@media (prefers-color-scheme: dark) {
    .mobile-bottom-nav {
        background: #1a1a1a;
        border-top-color: #333;
    }

    .mobile-nav-btn {
        color: #ccc;
    }

    .mobile-nav-btn.active {
        color: #4CAF50;
    }
}