/* --- DASHBOARD Y ESTADÍSTICAS (MODELO FINAL UNIFICADO) --- */
.header-unified-bar {
    background: white;
    padding: 8px 12px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    gap: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.header-unified-item {
    padding: 6px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 120px;
}

.unified-label {
    font-size: 9px;
    font-weight: 900;
    color: #64748b;
    margin-bottom: 4px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.unified-value-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(204, 102, 255, 0.08);
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid rgba(204, 102, 255, 0.2);
}

.unified-value-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.03);
    padding: 4px 12px;
    border-radius: 12px;
}

.unified-value-text {
    font-size: 1.1rem;
    font-weight: 900;
    color: #1e1b4b;
}

.unified-divider {
    width: 1px;
    height: 35px;
    background: rgba(0, 0, 0, 0.08);
}

.user-unified-trigger {
    background: rgba(79, 70, 229, 0.05);
    padding: 6px 16px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
    border: 1px solid rgba(79, 70, 229, 0.1);
    margin-left: 10px;
}

.user-unified-trigger:hover {
    background: rgba(79, 70, 229, 0.1);
}

.avatar-circle-xs {
    width: 28px;
    height: 28px;
    background: #4f46e5;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border: 2px solid white;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.white-content-area {
    background: white;
    border-top: 1px solid rgba(0,0,0,0.05);
}

/* BOTÓN CANJEAR */
.btn-canjear-purple {
    background: linear-gradient(to right, hsl(275, 80%, 45%), hsl(275, 100%, 20%));
    color: white;
    font-weight: 700;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 10px 25px -5px rgba(124, 58, 237, 0.4);
}

.btn-canjear-purple:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 20px 30px -10px rgba(124, 58, 237, 0.5);
    filter: brightness(1.1);
}

/* TARJETAS ESTADÍSTICAS (ESTILO CATÁLOGO PREMIUM) */
.premium-stat-card {
    background: white;
    border-radius: 28px;
    padding: 30px;
    display: flex;
    align-items: center;
    gap: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    border: 2px solid #f1f5f9; /* Increased border width to make active state clearer */
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

.premium-stat-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    border-color: #e2e8f0;
}

/* ESTADOS ACTIVOS PARA FILTROS */
.premium-stat-card.active {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
}

#cardRegistrados.active {
    border-color: #3b82f6;
    background: linear-gradient(to bottom right, #ffffff, #eff6ff);
}

#cardNoVentas.active {
    border-color: #f43f5e;
    background: linear-gradient(to bottom right, #ffffff, #fff1f2);
}

#cardVentas.active {
    border-color: #22c55e;
    background: linear-gradient(to bottom right, #ffffff, #f0fdf4);
}

.stat-icon-box {
    width: 70px;
    height: 70px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-info-right {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
    width: 100%;
    justify-content: flex-end;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: #475569;
    letter-spacing: 0.02em;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 900;
    color: #1e1b4b; /* Deep Indigo for visibility */
    line-height: 1;
}

/* Container for stat-items, assuming this was the intended block */
.stat-items-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

/* Clean up old stat-item styles */
/* The following rules are commented out or removed as per instruction to clean up old stat-item styles */
/*
.stat-item {
    background: white;
    padding: 40px 24px;
    border-radius: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid #eef2f6;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.05);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stat-item:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.08);
}

.stat-icon-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    transition: transform 0.3s ease;
}

.stat-item:hover .stat-icon-wrapper {
    transform: rotate(8deg);
}

.stat-content {
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
    letter-spacing: 0.05em;
    font-weight: 700;
}
*/
/* The .stat-item .stat-value rule is removed as per instruction */
/*
.stat-item .stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
*/

/* --- MODALES Y TIENDA --- */
.modal-content {
    background: white;
    border-radius: 28px;
    width: 100%;
    max-width: 550px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-premium);
    overflow: hidden;
    position: relative;
    transform: translateY(20px);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-content.modal-large {
    max-width: 1100px;
    width: 95vw;
}

/* Botón de cierre Premium */
.btn-close-premium {
    position: relative;
    z-index: 20;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    font-size: 32px;
    font-weight: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 0;
    padding-bottom: 5px;
}

.btn-close-premium:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg) scale(1.1);
    border-color: #fbbf24; /* amber-400 */
    color: #fbbf24;
}

.modal-header {
    padding: 24px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to right, hsl(275, 80%, 45%), hsl(275, 100%, 20%));
    color: white;
    position: relative;
    overflow: hidden;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: white;
    position: relative;
    z-index: 10;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.points-badge {
    background: rgba(255, 255, 100, 0.1);
    border: 1px solid rgba(255, 255, 100, 0.3);
    color: #fef08a; /* amber-200 */
    padding: 6px 14px;
    border-radius: 99px;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    backdrop-filter: blur(4px);
}

.points-badge strong {
    font-weight: 800;
    margin-left: 6px;
}

.btn-cart {
    padding: 10px;
    position: relative;
    border-radius: 12px;
}

.cart-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--error);
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    min-width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

.btn-close {
    background: #f1f5f9;
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-close:hover {
    background: #e2e8f0;
    color: var(--text-main);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
}

.modal-body.p-0 {
    padding: 0;
}

/* Tabla de Referidos */
table {
    border-spacing: 0;
}

th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #f8fafc;
}

tbody tr:last-child {
    border-bottom: none;
}

.stat-item.cursor-pointer {
    cursor: pointer;
}

/* Íconos en Tabla */
.table-item-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Grilla Premios */
.premios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.premio-card {
    background: white;
    border: 1px solid var(--input-border);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}

.premio-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.premio-img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #f1f5f9;
}

.premio-info {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.premio-info h3 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    color: var(--text-main);
}

.premio-info p {
    margin: 0 0 16px 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    flex: 1;
    line-height: 1.6;
}

.premio-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.premio-precio {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.25rem;
}

.btn-agregar {
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-agregar:hover {
    background: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.btn-agregar:active {
    transform: translateY(0);
}

.estado-agotado {
    color: var(--error);
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
    text-align: center;
    padding: 8px 12px;
    background: #fef2f2;
    border-radius: 10px;
}

.cart-item {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--input-border);
    padding: 16px;
    border-radius: 16px;
}

.cart-item-info {
    flex: 1;
}

.cart-item-title {
    margin: 0 0 4px 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-main);
}

.cart-item-price {
    margin: 0;
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 700;
}

.cart-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-icon {
    background: white;
    border: 1px solid var(--input-border);
    color: var(--text-main);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: hsla(var(--p-h), var(--p-s), var(--p-l), 0.05);
}

.cart-divider {
    border: none;
    border-top: 1px solid var(--input-border);
    margin: 24px 0;
}

.cart-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.cart-total {
    color: var(--primary);
    font-size: 1.75rem;
    font-weight: 800;
}

/* Empty Cart State */
.cart-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-muted);
}

.cart-empty-state .empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
    filter: grayscale(1);
}

.cart-empty-state h3 {
    color: var(--text-main);
    font-size: 1.25rem;
    margin-bottom: 10px;
    font-weight: 800;
}

.cart-empty-state p {
    font-size: 0.95rem;
    max-width: 250px;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .internal-stats-cards {
        width: 100%;
        justify-content: space-between;
    }
    
    .internal-stat-card {
        flex: 1;
        min-width: 0;
    }
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 640px) {

    /* Header Side-by-Side */
    header.flex.justify-between {
        flex-direction: row !important;
        align-items: center !important;
        gap: 15px;
        margin-bottom: 35px !important;
        padding-top: 10px;
        position: relative;
        z-index: 5000;
    }

    header .text-2xl {
        font-size: 1.1rem !important;
        max-width: 120px;
        line-height: 1.2;
    }

    .header-actions {
        width: auto;
    }

    .user-profile-container {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        background: rgba(255, 255, 255, 0.6);
        padding: 6px 12px;
        border-radius: 9999px;
        gap: 8px !important;
        border: 1px solid var(--card-border);
    }

    /* Name & Icon Row (Top) */
    .dropdown {
        width: auto;
    }

    .user-menu-trigger {
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        gap: 6px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        transform: none !important;
    }

    #headerUserName {
        display: inline !important;
        font-size: 0.9rem !important;
        margin: 0 !important;
        line-height: normal !important;
        font-weight: 700 !important;
    }

    .avatar-circle {
        width: 34px !important;
        height: 34px !important;
        transform: none !important;
        flex-shrink: 0;
    }

    /* Disable hover rotation on mobile */
    .user-menu-trigger:hover .avatar-circle {
        transform: none !important;
    }

    /* Stats Row (Bottom) */
    .header-stats-bar {
        width: auto !important;
        display: flex !important;
        gap: 12px !important;
        margin: 0 !important;
        scale: 1 !important;
    }

    .header-stat-item {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
    }

    .header-stat-item .label {
        display: block !important;
        font-size: 9px !important;
        color: var(--text-muted);
        text-transform: uppercase;
        font-weight: 700;
        letter-spacing: 0.025em;
    }

    #headerUserBadge,
    #headerUserPoints {
        font-size: 0.75rem !important;
        margin: 0 !important;
        padding: 2px 6px !important;
    }

    .header-stat-divider {
        display: none !important;
    }

    .logout-link {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Modal Fixes */
    .modal-content {
        height: 100vh !important;
        height: 100dvh !important;
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        border-radius: 0 !important;
        transform: none !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .modal-overlay.active .modal-content {
        transform: none !important;
    }

    .modal-body {
        padding: 15px !important;
    }

    .modal-header {
        padding: 24px 20px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        flex-direction: row !important; /* Volver a row para que fluya mejor */
        justify-content: space-between !important;
        align-items: flex-start !important;
        gap: 12px !important;
        position: relative !important;
    }

    .btn-close-premium {
        position: relative !important;
        top: 0 !important;
        right: 0 !important;
        margin-left: 10px !important;
        flex-shrink: 0 !important;
    }

    /* Especial para tienda que tiene más botones */
    .modal-header-actions {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }

    .premios-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

@media (max-width: 480px) {
    .header-actions {
        gap: 8px;
    }

    .btn-premium {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
}