/* ==========================================================================
   1. VARIABLES DE TEMA PREMIUM (LIGHT & DARK MODE DINÁMICO)
   ========================================================================== */
:root {
    --menu-bg: rgba(255, 255, 255, 0.88);
    --menu-border: rgba(226, 232, 240, 0.8);
    --menu-shadow: 0 14px 35px -5px rgb(15 23 42 / 18%), 0 0 0 1px rgba(255, 255, 255, 0.6); /* Sombra ajustada */
    
    --item-text: #64748b;
    --item-text-active: #4f46e5;
    
    /* Variables del Indicador Flotante (Gota/Glass) */
    --indicator-bg: linear-gradient(135deg, rgba(79, 70, 229, 0.15) 0%, rgba(99, 102, 241, 0.05) 100%);
    --indicator-border: rgba(79, 70, 229, 0.2);
    --indicator-shadow: 0 4px 12px rgba(79, 70, 229, 0.1), inset 0 1px 1px rgba(255, 255, 255, 0.6);

    --panico-bg: linear-gradient(135deg, #fff5f5 0%, #fee2e2 100%);
    --panico-text: #e11d48;
    --panico-border: rgba(244, 63, 94, 0.3);
    --panico-shadow: 0 4px 15px rgba(225, 29, 72, 0.15);

    --modal-overlay: rgba(15, 23, 42, 0.4);
    --modal-bg: #ffffff;
    --card-bg: #f8fafc;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(15, 23, 42, 0.06);
    --btn-text: #ffffff;
}

body.dark-mode {
    --menu-bg: rgba(18, 24, 35, 0.85); /* Mayor transparencia para el blur */
    --menu-border: rgba(255, 255, 255, 0.08);
    --menu-shadow: 0 16px 40px -5px rgb(0 0 0), 0 0 0 1px rgba(255, 255, 255, 0.05);
    
    --item-text: #94a3b8;
    --item-text-active: #818cf8;
    
    /* Variables del Indicador Flotante (Gota/Glass) Dark */
    --indicator-bg: linear-gradient(135deg, rgba(129, 140, 248, 0.25) 0%, rgba(79, 70, 229, 0.1) 100%);
    --indicator-border: rgba(129, 140, 248, 0.3);
    --indicator-shadow: 0 4px 15px rgba(129, 140, 248, 0.2), inset 0 1px 1px rgba(255, 255, 255, 0.1);

    --panico-bg: linear-gradient(135deg, rgba(136, 19, 55, 0.4) 0%, rgba(76, 5, 25, 0.6) 100%);
    --panico-text: #fb7185;
    --panico-border: rgba(251, 113, 133, 0.3);
    --panico-shadow: 0 4px 15px rgba(244, 63, 94, 0.25);

    --modal-overlay: rgba(2, 6, 23, 0.8);
    --modal-bg: #0f172a;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.06);
    --btn-text: #0f172a;
}

/* ==========================================================================
   2. ARQUITECTURA DEL MENÚ (2 FILAS)
   ========================================================================== */
.app-bottom-menu {
    position: fixed;
    bottom: 5px;
    left: 0 !important;
    right: 0 !important;
    margin: 0 auto !important;
    transform: none !important;
    width: 94%;
    max-width: 480px;
    height: auto; 
    background: var(--menu-bg);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1px solid var(--menu-border);
    border-radius: 32px;
    box-shadow: var(--menu-shadow);
    display: flex;
    flex-direction: column;
    padding: 12px 10px;
    gap: 12px;
    z-index: 99999;
    box-sizing: border-box;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-bottom-menu--guest {
    justify-content: center;
}

.app-bottom-menu-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    position: relative; /* Necesario para contexto de z-index */
}

/* ==========================================================================
   3. ITEMS DEL MENÚ Y EFECTO INDICADOR (NUEVO)
   ========================================================================== */
/* EL INDICADOR DESLIZANTE (LA GOTA) */
.nav-glass-indicator {
    position: absolute;
    top: 0;
    left: 0;
    background: var(--indicator-bg);
    border: 1px solid var(--indicator-border);
    box-shadow: var(--indicator-shadow);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 0;
    pointer-events: none; /* Que no bloquee clicks */
    /* Animación resorte (spring) */
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), 
                width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), 
                height 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), 
                opacity 0.25s ease,
                border-radius 0.3s ease;
    opacity: 0;
}

.menu-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none !important;
    color: var(--item-text);
    border-radius: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    z-index: 1; /* Los iconos van encima del indicador */
}

.menu-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.menu-label {
    font-weight: 600;
    line-height: 1;
    transition: color 0.3s ease, transform 0.3s ease;
    white-space: nowrap;
}

/* Efectos Generales y Hover */
.menu-item:hover .menu-icon-wrapper { transform: translateY(-2px); }
.menu-item:active { transform: scale(0.92); }

/* ESTADO ACTIVO (Sin background fijo, eso lo hace el indicador de JS) */
.menu-item.active {
    color: var(--item-text-active);
    /* Se quitó el background estático aquí */
}

.menu-item.active .menu-icon-wrapper {
    transform: translateY(-3px) scale(1.08); /* Salta un poco el icono al activarse */
}

.menu-item.active svg { 
    filter: drop-shadow(0 3px 6px rgba(79, 70, 229, 0.4)); 
}

.menu-item.active .menu-label { 
    font-weight: 700; 
}

/* ==========================================================================
   4. AJUSTES ESPECÍFICOS POR FILA
   ========================================================================== */
.app-bottom-menu-tabs {
    justify-content: space-between; 
}
.app-bottom-menu-tabs .menu-item {
    min-width: 42px; 
    height: 48px;
    padding: 4px 6px;
}
.app-bottom-menu-tabs .menu-icon-wrapper {
    width: 22px;
    height: 22px;
}
.app-bottom-menu-tabs .menu-item svg {
    width: 20px;
    height: 20px;
    transition: color 0.25s ease, filter 0.25s ease;
}
.app-bottom-menu-tabs .menu-label {
    font-size: 9px;
    margin-top: 2px;
    letter-spacing: -0.3px;
}

/* FILA 2: Acciones */
.app-bottom-menu-actions .menu-item {
    min-width: 58px;
    height: 52px;
    padding: 0 8px;
}
.app-bottom-menu-actions .menu-item.active {
    padding: 0 14px;
}
.app-bottom-menu-actions .menu-icon-wrapper {
    width: 24px;
    height: 24px;
}
.app-bottom-menu-actions .menu-item svg {
    width: 22px;
    height: 22px;
}
.app-bottom-menu-actions .menu-label {
    font-size: 10.5px;
    letter-spacing: -0.2px;
}

/* ==========================================================================
   5. BOTONES ESPECIALES: PÁNICO Y CHAT BADGE
   ========================================================================== */
/* Animación de latido sutil para el Pánico */
@keyframes pulse-panico {
    0% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(225, 29, 72, 0); }
    100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0); }
}

.menu-item--panico {
    background: var(--panico-bg);
    color: var(--panico-text) !important;
    border: 1px solid var(--panico-border);
    box-shadow: var(--panico-shadow);
    animation: pulse-panico 2.5s infinite cubic-bezier(0.66, 0, 0, 1);
}
.menu-item--panico:hover { 
    box-shadow: 0 6px 20px rgba(225, 29, 72, 0.3); 
    animation: none; 
}
.menu-item--panico-disabled { opacity: 0.5; filter: grayscale(0.3); cursor: not-allowed; animation: none; }

.chat-menu-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    color: #ffffff;
    font-size: 9px;
    font-weight: 800;
    padding: 2px 4px;
    border-radius: 12px;
    min-width: 14px;
    text-align: center;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(225, 29, 72, 0.4), 0 0 0 2px var(--menu-bg);
    z-index: 10;
}

/* ==========================================================================
   6. MODALES PREMIUM
   ========================================================================== */
.app-premium-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--modal-overlay);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 100000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.app-premium-modal.open { opacity: 1; pointer-events: auto; }

.app-modal-card {
    background: var(--modal-bg);
    width: 100%;
    max-width: 480px;
    border-radius: 36px 36px 0 0;
    border-top: 1px solid var(--menu-border);
    padding: 20px 24px 44px 24px;
    box-sizing: border-box;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.1), background 0.3s ease;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.2);
}

.app-premium-modal.open .app-modal-card { transform: translateY(0); }

@media (min-width: 600px) {
    .app-premium-modal { align-items: center; padding: 20px; }
    .app-modal-card { border-radius: 32px; transform: scale(0.9); border: 1px solid var(--menu-border); }
    .app-premium-modal.open .app-modal-card { transform: scale(1); }
}

.app-modal-drag-handle { width: 44px; height: 5px; background: var(--item-text); opacity: 0.2; border-radius: 4px; margin: 0 auto 20px auto; }
.app-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.app-modal-header h3 { margin: 0; font-size: 22px; font-weight: 700; color: var(--text-main); letter-spacing: -0.5px; }

.app-modal-close {
    background: var(--border-color); border: none; width: 36px; height: 36px; border-radius: 50%; font-size: 20px;
    cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-muted); transition: all 0.2s ease;
}
.app-modal-close:hover { background: var(--item-bg-active); color: var(--item-text-active); }

/* Listado de Ajustes y Modal Pánico */
.settings-list { display: flex; flex-direction: column; gap: 12px; }
.setting-row-item { display: flex; align-items: center; justify-content: space-between; background: var(--card-bg); border: 1px solid var(--border-color); padding: 16px; border-radius: 22px; gap: 14px; transition: all 0.3s ease; }
.setting-meta-side { display: flex; align-items: center; gap: 14px; flex: 1; }
.setting-icon-wrapper { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 16px; background: rgba(79, 70, 229, 0.1); color: var(--item-text-active); flex-shrink: 0; }
.setting-details h4 { margin: 0 0 3px 0; font-size: 15px; font-weight: 600; color: var(--text-main); }
.setting-details p { margin: 0; font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.btn-row-action { background: var(--item-text-active); color: var(--btn-text) !important; border: none; padding: 10px 18px; border-radius: 14px; font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.2s ease; white-space: nowrap; box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2); }
.btn-row-action:active { transform: scale(0.95); }
.btn-row-action--success { background: #10b981; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2); }

.modal-panico-card { border-top: 5px solid #f43f5e; }
.modal-panico-title { color: #f43f5e; text-align: center; margin-top: 0; }
.modal-panico-desc { text-align: center; font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.modal-panico-select { width: 100%; padding: 14px; margin-bottom: 15px; border-radius: 14px; border: 2px solid rgba(244, 63, 94, 0.3); font-weight: 600; background: var(--card-bg); color: var(--text-main); outline: none; }
.modal-panico-input { width: 100%; padding: 16px; font-size: 22px; text-align: center; letter-spacing: 4px; border-radius: 14px; border: 2px solid var(--border-color); margin-bottom: 24px; background: var(--card-bg); color: var(--text-main); box-sizing: border-box; outline: none; }
.btn-panico-submit { width: 100%; padding: 16px; background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%); color: white; font-weight: 800; font-size: 16px; border: none; border-radius: 16px; cursor: pointer; box-shadow: 0 8px 25px rgba(225, 29, 72, 0.35); transition: transform 0.2s ease; }
.btn-panico-submit:active { transform: scale(0.97); }

/* ==========================================================================
   7. NUEVOS BOTONES: TEMA Y LOGOUT
   ========================================================================== */
.theme-icon-light, .theme-icon-dark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.theme-icon-light img, .theme-icon-dark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.menu-item--logout {
    color: #e11d48 !important;
}

.menu-item--logout svg {
    color: #e11d48;
}

.menu-item--logout:active {
    transform: scale(0.92);
}

body.dark-mode .menu-item--logout, body.dark-mode .menu-item--logout svg {
    color: #fb7185 !important;
}