:root {
    --primary: #ff0080;
    --secondary: #00bfff;
    --accent: #ffdd00;
    
    /* COLORES BASE MODO CLARO */
    --bg-main: #f8f9fa;
    --bg-card: #ffffff;
    --text-main: #2d3436;
    --text-muted: #636e72;
    --border-color: #eee;
    --nav-bg: rgba(255, 255, 255, 0.95);
    
    --font-main: 'Fredoka', sans-serif;
}

/* PALETA DE COLORES MODO OSCURO GLOBAL */
body.dark-mode {
    --bg-main: #121212;
    --bg-card: #1e272e;
    --text-main: #dfe6e9;
    --text-muted: #a4b0be;
    --border-color: #4a5459;
    --nav-bg: rgba(30, 39, 46, 0.95);
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-main);
    color: var(--text-main);
    background-image: radial-gradient(rgba(255, 0, 128, 0.05) 15%, transparent 16%),
                      radial-gradient(rgba(0, 191, 255, 0.05) 15%, transparent 16%);
    background-size: 50px 50px;
    background-position: 0 0, 25px 25px;
    margin: 0;
    padding: 20px;
    padding-top: 90px; /* Espacio para la barra fija */
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* --- BARRA DE NAVEGACIÓN GLOBAL --- */
.global-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 70px;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    border-bottom: 2px solid var(--border-color);
    z-index: 1000;
    transition: background 0.4s ease, border-color 0.4s ease;
}

.global-nav .brand {
    font-size: 1.5rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.user-status {
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative; /* Importante para el desplegable */
}

/* --- INTERRUPTOR MODO OSCURO (NUEVO) --- */
.theme-toggle {
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: 0.3s;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.theme-toggle:hover { background: var(--bg-card); color: var(--primary); }

/* --- ESTILOS NOTIFICACIONES --- */
.nav-item-notif {
    position: relative;
    cursor: pointer;
    font-size: 1.4rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.3s;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}
.nav-item-notif:hover { background: var(--bg-card); color: var(--primary); }

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--primary);
    color: white;
    font-size: 0.7rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: none; /* Se activa por JS */
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-card);
    font-weight: 600;
}

/* PANEL DESPLEGABLE DE NOTIFICACIONES */
.notif-dropdown {
    position: absolute;
    top: 60px;
    right: 0;
    width: 320px;
    background: var(--bg-card);
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.15);
    border: 1px solid var(--border-color);
    display: none; /* Toggle por JS */
    flex-direction: column;
    overflow: hidden;
    z-index: 2000;
    animation: fadeInNotif 0.3s ease;
}

@keyframes fadeInNotif {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.notif-header {
    padding: 15px 20px;
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.notif-list {
    max-height: 350px;
    overflow-y: auto;
}

.notif-item {
    display: flex;
    gap: 12px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: 0.2s;
    align-items: center;
    text-decoration: none;
    color: var(--text-main);
}
.notif-item:hover { background: var(--bg-main); }

.notif-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.notif-content { flex: 1; font-size: 0.85rem; line-height: 1.3; }
.notif-content b { color: var(--primary); }
.notif-time {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.notif-empty { padding: 30px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }

/* --- FIN NOTIFICACIONES --- */

.credits-badge {
    background: rgba(251, 192, 45, 0.1);
    color: #fbc02d;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 600;
    border: 2px solid #fbc02d;
    box-shadow: 0 2px 0 rgba(249, 168, 37, 0.3);
}

.avatar-mini {
    width: 40px; height: 40px;
    background-color: var(--bg-main);
    background-image: url('https://cdn-icons-png.flaticon.com/512/4140/4140048.png');
    background-size: cover;
    border-radius: 50%;
    border: 2px solid var(--secondary);
    cursor: pointer;
}

/* --- ESTILOS COMUNES --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--bg-card);
    padding: 30px;
    border-radius: 25px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
    transition: background 0.4s ease, border-color 0.4s ease;
}

h1, h2, h3, h4 { color: var(--text-main); margin-bottom: 15px; }
p.subtitle { text-align: center; color: var(--text-muted); margin-bottom: 30px; }

/* Inputs y Controles */
label { display: block; font-weight: 600; margin-bottom: 8px; color: var(--text-main); }
input, select, textarea {
    width: 100%; padding: 12px; border: 2px solid var(--border-color);
    border-radius: 10px; font-family: var(--font-main);
    margin-bottom: 15px; box-sizing: border-box;
    transition: 0.3s;
    background: var(--bg-card);
    color: var(--text-main);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; }

/* Botones */
.btn-action {
    width: 100%;
    background: var(--secondary);
    color: white; border: none;
    padding: 15px; font-size: 1.2rem; font-weight: 600;
    border-radius: 12px; cursor: pointer;
    transition: 0.2s; box-shadow: 0 5px 0 #0097a7;
    text-transform: uppercase;
}
.btn-action:hover { transform: translateY(-3px); filter: brightness(1.1); }
.btn-action:active { transform: translateY(2px); box-shadow: none; }

.btn-back {
    display: inline-block; text-decoration: none;
    color: var(--text-muted); font-weight: 600; margin-bottom: 20px;
}

/* BOTÓN CERRAR SESIÓN */
.btn-logout {
    background: #ff7675;
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    transition: 0.2s;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.btn-logout:hover {
    background: #d63031;
    transform: scale(1.1);
}

/* --- NUEVO: FILTROS RÁPIDOS (PILLS) --- */
.filters-container {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}
.filter-pill {
    background: var(--bg-main);
    color: var(--text-muted);
    border: 2px solid var(--border-color);
    padding: 8px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
    font-family: var(--font-main);
}
.filter-pill:hover { background: var(--bg-card); color: var(--primary); border-color: var(--primary); }
.filter-pill.active { background: var(--primary); color: white; border-color: var(--primary); }

/* --- SISTEMA DE REFERIDOS --- */
.referral-container {
    background: var(--bg-card);
    border-radius: 25px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.06);
    border: 3px solid #54a0ff;
    display: none;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.referral-grid {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.ref-input {
    flex: 1;
    min-width: 250px;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.9rem;
    background: var(--bg-main);
    color: var(--text-main);
    margin-bottom: 0 !important;
}

.btn-copy, .btn-whatsapp-ref {
    border: none;
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
    text-decoration: none;
}

.btn-copy { background: #54a0ff; }
.btn-copy:hover { background: #2e86de; transform: translateY(-2px); }

.btn-whatsapp-ref { background: #25D366; }
.btn-whatsapp-ref:hover { background: #128C7E; transform: translateY(-2px); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- REGLAS EXCLUSIVAS PARA CELULAR (SOLO SE APLICAN EN MÓVIL) --- */
@media (max-width: 767px) {
    body {
        padding: 10px;
        padding-top: 80px;
        background-size: 30px 30px;
    }
    
    .global-nav {
        height: 60px;
        padding: 0 15px;
    }
    
    .container {
        padding: 15px;
        border: none; /* Quitamos bordes en móvil para ganar espacio */
    }

    /* Forzamos el menú a 2 columnas en el móvil */
    .tools-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    .tool-card {
        padding: 15px !important;
    }

    .tool-card p {
        display: none !important; /* Ocultamos descripción larga solo en móvil */
    }

    /* Centramos notificaciones para que no se corten */
    .notif-dropdown {
        position: fixed;
        left: 10px;
        right: 10px;
        width: auto;
        top: 70px;
    }
}